The root_path parameter of the FastAPI object doesn't work in "Behind a Proxy" #11033
Replies: 5 comments 10 replies
-
It is unclear to me to what the issue is specifically? The behaviour you describe is expected behaviour. When you set INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO: 127.0.0.1:56310 - "GET /proxy/app HTTP/1.1" 200 OK
INFO: 127.0.0.1:51872 - "GET /proxy/subapi/sub HTTP/1.1" 200 OK |
Beta Was this translation helpful? Give feedback.
-
Perhaps there is an issue with my description. I am currently using a proxy like /dev-api in the Vue project to request static files under the fastapis service. I can retrieve files normally by specifying root-path as /dev-api using uvicorn, but only specifying the root_path parameter in the fastapis object cannot retrieve static files. I think this is a similar issue to #10948 and #10978. If my idea is incorrect, please correct it. |
Beta Was this translation helpful? Give feedback.
-
Hello @insistence , I saw that the problem was solved when you gave a root_path to the sub application you created. I hope the answer you want is this way.
The operating system I use ubuntu. All other dependencies are the same as the dependencies you mentioned. If the solution you want is not this, I can try to help you if you can eleborate a bit more. Happy coding 😃 |
Beta Was this translation helpful? Give feedback.
-
Just adding an additional datapoint here.
can only be accessed via the Downgrading back to 0.104.1 resolves the issue. Note that I've tried to upgrade to 0.109.2 that was recently released and the same issue is occurring as with 0.109.0 |
Beta Was this translation helpful? Give feedback.
-
I think I might've fixed this in #11160 I was having an issue with the 307 redirect that happens when you don't include the trailing slash, when running behind a proxy the |
Beta Was this translation helpful? Give feedback.
-
First Check
Commit to Help
Example Code
Description
When I run the code, the server is expecting that I include the defined root path e.g:
http://localhost:8000/subapi/sub is not working (404)
http://localhost:8000/proxy/subapi/sub is working
IN version 0.108.0 It works as described here https://fastapi.tiangolo.com/advanced/behind-a-proxy/
My uvicorn version is 0.27.0
Thanks
Operating System
Windows
Operating System Details
No response
FastAPI Version
0.109.0
Pydantic Version
2.5.3
Python Version
3.9.18
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions