Skip to content

Reverse proxy and sub-apps

The ASGI root_path FastAPI sets when an app runs behind a proxy or is mounted with app.mount() is picked up automatically in every per-version doc URL:

parent = FastAPI()
parent.mount("/api", app)  # root_path="/api" is injected per request
# /api/v1_0/docs correctly points at /api/v1_0/openapi.json

A mounted sub-application is a separate FastAPI() instance, so a RouterVersioner attached to it is entirely independent from one attached to the parent, or to another sub-application, with no prefix coordination needed. See examples/mounted_subapps_app.py.