From: Sebastián Ramírez Date: Wed, 29 Jul 2026 15:27:41 +0000 (+0200) Subject: 📝 Document `FASTAPI_ENV` in FastAPI CLI guide (#16104) X-Git-Tag: 0.141.1~4 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=8a1f8768411e62093e70ce142ea10863a485643c;p=thirdparty%2Ffastapi%2Ffastapi.git 📝 Document `FASTAPI_ENV` in FastAPI CLI guide (#16104) --- diff --git a/docs/en/docs/fastapi-cli.md b/docs/en/docs/fastapi-cli.md index c10218849..e7b04060e 100644 --- a/docs/en/docs/fastapi-cli.md +++ b/docs/en/docs/fastapi-cli.md @@ -119,6 +119,10 @@ Running `fastapi dev` initiates development mode. By default, **auto-reload** is enabled, automatically reloading the server when you make changes to your code. This is resource-intensive and could be less stable than when it's disabled. You should only use it for development. It also listens on the IP address `127.0.0.1`, which is the IP for your machine to communicate with itself alone (`localhost`). +Before importing your app, `fastapi dev` sets the `FASTAPI_ENV` environment variable to `development`. If `FASTAPI_ENV` is already set, its existing value is preserved. This lets app startup code choose development-friendly behavior while allowing you to provide an app-specific environment such as `staging`. + +The conventional `FASTAPI_ENV` values are `development` and `production`. `fastapi run` currently leaves `FASTAPI_ENV` unchanged, so set it explicitly if your app needs to detect production mode. + ## `fastapi run` { #fastapi-run } Executing `fastapi run` starts FastAPI in production mode.