Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Fix root_path behavior #11160

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

richin13
Copy link

@richin13 richin13 commented Feb 18, 2024

Description

I came across a bug with setting the root_path value directly into the FastAPI app. The docs state:

Passing the root_path to FastAPI would be the equivalent of passing the --root-path command line option to Uvicorn or Hypercorn.

But that wasn't the case since providing the --root-path option to Uvicorn or Hypercorn makes it so that the scope's path and raw_path contain the root_path. The behavior in FastAPI was to patch the scope's root_path value only, leaving the path and raw_path unchanged.

When running behind a proxy, this would cause the 307 redirect on missing trailing slashes to set the Location header to the path without the root_path value, resulting in a 404 error.

@insistence
Copy link

@tiangolo Excuse me, would it be convenient for you to prioritize this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants