alexschimpf / fastapi-versionizer

FastAPI Versionizer
MIT License
81 stars 13 forks source link

fix: Fixed issue with missing root_path for versioned doc pages #41

Closed worldworm closed 1 year ago

worldworm commented 1 year ago

Pull Request Checklist

Description

Hi, it's me again. πŸ˜„ I run some apis behind a reverse proxy in combination with a frontend. Therefore, the frontend is played out directly under / and the api accordingly under /api. In the reverse proxy I then make a stripPrefix so that it is passed on to fastapi without the prefix. In fastapi I have defined /api as root_path. All API routes remain identical, only the open-api route is changed so that the prefix is correct again in the frontend. With fastapi-versionizer, however, this only works for the main docs. All versioned docs no longer work. Main doc Versioned Doc
grafik grafik

How To Test

That's described here: https://fastapi.tiangolo.com/advanced/behind-a-proxy/#testing-locally-with-traefik Just replace the prefix (two times) from the routes.toml from "/api/v1" to "/api". Then you can run: uvicorn examples.with_root_path:app --reload

Note

Here is described, that you can set a path prefix with uvicorn directly. My problem is, that the app.root_path attribute from fastapi stays empty in this case. I've had a look at the fastapi sourcecode, but I can't find where the uvicorn value comes from. So currently it only works if you set FastAPI(root_path='/api') directly.

alexschimpf commented 1 year ago

Btw I just merged a new PR, so you've got conflicts now.

worldworm commented 1 year ago

@alexschimpf The conflicts are resolved and the servers field is now using the app's one. πŸ˜ƒ

alexschimpf commented 1 year ago

:tada: This PR is included in version 3.0.1 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: