Replies: 1 comment 3 replies
-
I can't wait for this issue to be fixed ! It's one of those things that really bothers me with FastAPI |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Motivation:
Many users, particularly those using FastAPI (which is built on Starlette), may have encountered a common issue: their application works flawlessly in a local development environment but fails when deployed behind a proxy setup. The reason is temporary redirects, which are triggered by default when a registered route differs from a request only in a trailing slash.
Proposal:
I propose adding a new flag to the Router class:
redirect_slashes_internally
.When this flag is enabled, the Router resolves requests with mismatched trailing slashes internally, without issuing a temporary redirect. This change would only require a minor update to the Router.app method, as shown below:
Example:
In the end, you could create an router as follows:
In this setup, requests to both "/withslash" and "/withoutslash/" are resolved internally
I’d love to hear your thoughts on this proposal :)
Beta Was this translation helpful? Give feedback.
All reactions