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: Kludex/uvicorn#2213
More details in the Starlette PR: Kludex/starlette#2400
Originally posted by neugeeug January 12, 2024
First Check
Commit to Help
Example Code
uvicorn rest.main:server --host 0.0.0.0 --port 8080 --reload --root-path /proxy
server = FastAPI()
# separate spec at /v1/docs
server.mount("/v1", app_v1)
# separate spec at /v2/docs
server.mount("/v2", app_v2)
#where app_v1, app_v2 is like below
app_v1 = FastAPI(openapi_tags=tags_metadata, title="Pet store")
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
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: Kludex/uvicorn#2213
More details in the Starlette PR: Kludex/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-pathoption 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