Replies: 4 comments 4 replies
-
|
What's the uvicorn version? If it's not the latest one, try it. |
Beta Was this translation helpful? Give feedback.
-
|
I think I've found where the issue came from. |
Beta Was this translation helpful? Give feedback.
-
|
I can confirm I am also seeing this issue using fastapi v0.115.0 with starlette v0.38.6. I a building an API on a subsite and want the root request to auto resdirect to the docs page |
Beta Was this translation helpful? Give feedback.
-
|
The thing here is that you shouldn't strip path prefix when you specify According to ASGI spec, IMO, this is a mistake in docs and I attempt to fix it in this PR: #14238 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
The program runs in gunicorn (using the uvicorn worker class) behind a nginx proxy which strips away the root_path (as described in Behind a proxy).
Before fastapi 0.109 an URL with a trailing slash (ex. https://127.0.0.1/wms/hello/) would be redirected to the corresponding URL without the trailing slash (ex. https://127.0.0.1/wms/hello) as expected.
From fastapi 0.109 the redirect no more includes the root_path, so from https://127.0.0.1/wms/hello/ the application redirects to https://127.0.0.1/hello which results in a 404 Not Found error.
Here the headers of the redirect request:

I think the issue is correlated to this one but it's not really the same.
Operating System
Linux
Operating System Details
The server runs on Redhat 8.7
FastAPI Version
0.109.2
Pydantic Version
2.6.1
Python Version
3.9.13
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions