-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Behind a Proxy" changed behaviour in the new version 0.109.0 (in Uvicorn) #10978
Comments
Just to clear it up, in 0.110.0, the behavior would be the same as 0.108.0? |
This was solved in the latest uvicorn: https://github.com/encode/uvicorn/releases/tag/0.26.0 |
Now using uvicorn works well, but the root_path parameter of the FastAPI object still doesn't work |
Thanks @insistence, please create a new discussion question with your use case and an example that I can copy-paste to see what is not working, thanks! ☕ |
Thanks for your quick reply! The new discussion question is #11033 |
I already have a directory called static, which contains a file such as test.txt. When I run the code, I can only access it by http://127.0.0.1:8000/proxy/profile/test.txt in a browser. I can't access it by http://127.0.0.1:8000/profile/test.txt in a browser.
I would like to confirm if this is a bug in FastAPI. Can you help me? The discussion question is #11033 |
@insistence this looks like expected behavior because when you add a |
What confuses me is that the running results of these two pieces of code are inconsistent. This seems to be inconsistent with the description in the official document (https://fastapi.tiangolo.com/advanced/behind-a-proxy/#setting-the-root_path-in-the-fastapi-app). According to the official documentation, the results obtained by setting the root_path parameter to uvicorn or to FastAPI should be consistent. |
Ah Indeed! I'm sorry I missed that part. So the problem is that uvicorn's root path is not propagated to fastapi. |
I'm also having an issue with 026 post, see encode/uvicorn#2244 (comment) |
This comment was marked as duplicate.
This comment was marked as duplicate.
@Mattiam2 can you please log an issue for this? Because I think writing here we would not get attention easily since this issue shows up as |
Discussed in #10948
This is related to a change in Starlette and Uvicorn, making them more formally follow the ASGI spec, Starlette already does since version 0.35.0 (recently), Uvicorn needs an equivalent change, in process on: encode/uvicorn#2213
More details in the Starlette PR: encode/starlette#2400
Originally posted by neugeeug January 12, 2024
First Check
Commit to Help
Example Code
Description
When I run the uvicorn with the
--root-path
option for the above setup, the server is expecting that I include the defined root path in every request e.g:http://localhost:8080/v2/docs is not working (404)
http://localhost:8080/proxy/v2/docs is working
IN version 0.108.0 It works as described here https://fastapi.tiangolo.com/advanced/behind-a-proxy/
Operating System
Linux
Operating System Details
No response
FastAPI Version
0.109.0
Pydantic Version
2.5.3
Python Version
3.11.5
Additional Context
No response
The text was updated successfully, but these errors were encountered: