FastAPI has shipped 0.146.0, a release that changes how applications declare the URL prefix they are mounted behind. The release notes label this a breaking change: the root_path parameter accepted by the FastAPI() constructor is now deprecated. Instead of configuring the prefix in application code, the framework directs developers to set it at the server level using the fastapi run command with the --root-path flag.
The concrete changes in this release are short:
- Deprecate the
root_pathparameter passed to theFastAPI()application constructor (PR #16520 by @tiangolo). - Recommend configuring the server instead, e.g.
fastapi run --root-path /api/v1.
The rationale follows the usual FastAPI deployment model: root_path describes the prefix that a reverse proxy or gateway strips before forwarding a request to the ASGI app. Because that boundary belongs to the server and its deployment environment, moving it to a CLI flag keeps application code free of environment-specific assumptions. The same setting can then differ across staging, production and local runs without touching the codebase, and container images or platform configs can carry the prefix alongside the command that launches them.
For developers, the practical step is to audit every place root_path is passed to FastAPI(). If your app already sets it there, migrate to the --root-path flag in your run command, or pass root_path through your ASGI server when running under Uvicorn or Gunicorn directly. Deprecation means existing code still works for now, but expect warnings and eventual removal, so handling this early avoids a future upgrade surprise. Applications whose prefix only matters behind a proxy should see no behaviour change once the flag is in place, while teams gain a cleaner separation between app logic and deployment configuration. Teams maintaining shared templates and internal boilerplates should update those first, since a single change there propagates across every service that starts the app the same way.
Source: https://github.com/fastapi/fastapi/releases/tag/0.146.0