From 8a1f8768411e62093e70ce142ea10863a485643c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Wed, 29 Jul 2026 17:27:41 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20Document=20`FASTAPI=5FENV`=20in?= =?UTF-8?q?=20FastAPI=20CLI=20guide=20(#16104)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/docs/fastapi-cli.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/en/docs/fastapi-cli.md b/docs/en/docs/fastapi-cli.md index c102188493..e7b04060e9 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.