From 3e6c2c6bdd9377f46cdf36e4dcb59e04f449d500 Mon Sep 17 00:00:00 2001 From: Yurii Motov Date: Tue, 25 Nov 2025 17:08:33 +0100 Subject: [PATCH] Add a note in `behinf-a-proxy.md` --- docs/en/docs/advanced/behind-a-proxy.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/en/docs/advanced/behind-a-proxy.md b/docs/en/docs/advanced/behind-a-proxy.md index f692a28e8..d67688988 100644 --- a/docs/en/docs/advanced/behind-a-proxy.md +++ b/docs/en/docs/advanced/behind-a-proxy.md @@ -394,6 +394,14 @@ This is a more advanced use case. Feel free to skip it. By default, **FastAPI** will create a `server` in the OpenAPI schema with the URL for the `root_path`. +/// note | Technical Details + +The `servers` property in the OpenAPI specification is optional. + +If you don't specify the `servers` parameter and `root_path` is equal to `/`, the `servers` property in the generated OpenAPI schema will be omitted entirely. Clients should interpret this as a single server with a `url` value of `/`. + +/// + But you can also provide other alternative `servers`, for example if you want *the same* docs UI to interact with both a staging and a production environment. If you pass a custom list of `servers` and there's a `root_path` (because your API lives behind a proxy), **FastAPI** will insert a "server" with this `root_path` at the beginning of the list.