Skip to content

fix(nginx): add redirect for /api/v2/ trailing slash#2224

Merged
B4nan merged 1 commit intomasterfrom
claude/slack-add-queue-index-nk5XI
Feb 5, 2026
Merged

fix(nginx): add redirect for /api/v2/ trailing slash#2224
B4nan merged 1 commit intomasterfrom
claude/slack-add-queue-index-nk5XI

Conversation

@B4nan
Copy link
Member

@B4nan B4nan commented Feb 5, 2026

When accessing /api/v2/ with a trailing slash, the page returned a 404 error. This adds a redirect to remove the trailing slash, matching the behavior of other similar paths like /sdk/js/, /cli/, etc.

Slack thread: https://apify.slack.com/archives/C0L33UM7Z/p1770281199186039

https://claude.ai/code/session_01GqcrG6JU9Y1YaSA5ns87Yz


Note

Low Risk
Single redirect rule change in nginx.conf; low blast radius and no auth/data-handling logic involved.

Overview
Fixes a 404 when hitting the API reference index with a trailing slash by adding an Nginx rewrite that redirects /api/v2/ to /api/v2, aligning this path with existing trailing-slash normalization for other docs entrypoints.

Written by Cursor Bugbot for commit d6094b4. Configure here.

@B4nan B4nan added the adhoc Ad-hoc unplanned task added during the sprint. label Feb 5, 2026
@github-actions github-actions bot added this to the 133rd sprint - Tooling team milestone Feb 5, 2026
@github-actions github-actions bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Feb 5, 2026
@apify-service-account
Copy link

Preview for this PR was built for commit d6094b4 and is ready at https://pr-2224.preview.docs.apify.com!

@B4nan B4nan requested a review from barjin February 5, 2026 09:02
@B4nan
Copy link
Member Author

B4nan commented Feb 5, 2026

The preview link is unfortunately not usable to test this, it has its own nginx IIRC. Server redirects are not working in the previews, even the old ones that work fine in production.

Copy link
Member

@barjin barjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only fixes the one /api/v2/ URL.

Note that every other trailing-slash URL served by Docusaurus has the same issue (https://docs.apify.com/academy/, https://docs.apify.com/academy/puppeteer-playwright/ etc.)

I see little sense in adding only this if we don't fix all the other ones.

@B4nan B4nan force-pushed the claude/slack-add-queue-index-nk5XI branch from d6094b4 to dd0a048 Compare February 5, 2026 09:10
@B4nan
Copy link
Member Author

B4nan commented Feb 5, 2026

Let's hope we won't have to revert this, it feels a bit scary :]

@B4nan B4nan requested a review from barjin February 5, 2026 09:13
@apify-service-account
Copy link

Preview for this PR was built for commit dd0a048 and is ready at https://pr-2224.preview.docs.apify.com!

@B4nan
Copy link
Member Author

B4nan commented Feb 5, 2026

Hmm, this is in direct conflict with #2213, will just add a new rule behind those.

Adds a general rewrite rule to remove trailing slashes from all URLs
(except root /). This fixes the 404 error when accessing URLs like
/api/v2/ with a trailing slash.

The regex `^(.+)/$` matches any path with a trailing slash and redirects
to the same path without it. The existing specific rules for GH pages
docs are kept intact to avoid conflicts with other PRs.

Slack thread: https://apify.slack.com/archives/C0L33UM7Z/p1770281199186039

https://claude.ai/code/session_01GqcrG6JU9Y1YaSA5ns87Yz
@B4nan B4nan force-pushed the claude/slack-add-queue-index-nk5XI branch from dd0a048 to a62ea26 Compare February 5, 2026 09:16
@apify-service-account
Copy link

Preview for this PR was built for commit a62ea26 and is ready at https://pr-2224.preview.docs.apify.com!

Copy link
Member

@barjin barjin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's more like it, let's go! 😄

Comment on lines +457 to +464
rewrite ^/api/client/js/$ /api/client/js redirect;
rewrite ^/api/client/python/$ /api/client/python redirect;
rewrite ^/sdk/js/$ /sdk/js redirect;
rewrite ^/sdk/python/$ /sdk/python redirect;
rewrite ^/cli/$ /cli redirect;

# remove trailing slashes from all other URLs (except root /)
rewrite ^(.+)/$ $1 redirect;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling that the rules above are still included in the new regex (and therefore unnecessary), but this shouldn't hurt anything anyway 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rules above are exactly what I meant by a conflict with another PR #2213

There are likely more places we can drop, let's clean it up later once the landing page PRs are merged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, it's not merged yet

@B4nan B4nan merged commit dd83eaf into master Feb 5, 2026
13 checks passed
@B4nan B4nan deleted the claude/slack-add-queue-index-nk5XI branch February 5, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants