]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Update includes in `docs/en/docs/advanced/behind-a-proxy.md` (#12583)
authorJulio Anthony Leonard <JulioAnthonyLeonard@gmail.com>
Sun, 27 Oct 2024 16:49:49 +0000 (17:49 +0100)
committerGitHub <noreply@github.com>
Sun, 27 Oct 2024 16:49:49 +0000 (16:49 +0000)
docs/en/docs/advanced/behind-a-proxy.md

index 67718a27b03fca906d5db37fbf4986b76d9bb0c5..87a62e88b7f5dd95f217b023b74cdba39f01ad38 100644 (file)
@@ -18,9 +18,7 @@ In this case, the original path `/app` would actually be served at `/api/v1/app`
 
 Even though all your code is written assuming there's just `/app`.
 
-```Python hl_lines="6"
-{!../../docs_src/behind_a_proxy/tutorial001.py!}
-```
+{* ../../docs_src/behind_a_proxy/tutorial001.py hl[6] *}
 
 And the proxy would be **"stripping"** the **path prefix** on the fly before transmitting the request to the app server (probably Uvicorn via FastAPI CLI), keeping your application convinced that it is being served at `/app`, so that you don't have to update all your code to include the prefix `/api/v1`.
 
@@ -98,9 +96,7 @@ You can get the current `root_path` used by your application for each request, i
 
 Here we are including it in the message just for demonstration purposes.
 
-```Python hl_lines="8"
-{!../../docs_src/behind_a_proxy/tutorial001.py!}
-```
+{* ../../docs_src/behind_a_proxy/tutorial001.py hl[8] *}
 
 Then, if you start Uvicorn with:
 
@@ -127,9 +123,7 @@ The response would be something like:
 
 Alternatively, if you don't have a way to provide a command line option like `--root-path` or equivalent, you can set the `root_path` parameter when creating your FastAPI app:
 
-```Python hl_lines="3"
-{!../../docs_src/behind_a_proxy/tutorial002.py!}
-```
+{* ../../docs_src/behind_a_proxy/tutorial002.py hl[3] *}
 
 Passing the `root_path` to `FastAPI` would be the equivalent of passing the `--root-path` command line option to Uvicorn or Hypercorn.
 
@@ -309,9 +303,7 @@ If you pass a custom list of `servers` and there's a `root_path` (because your A
 
 For example:
 
-```Python hl_lines="4-7"
-{!../../docs_src/behind_a_proxy/tutorial003.py!}
-```
+{* ../../docs_src/behind_a_proxy/tutorial003.py hl[4:7] *}
 
 Will generate an OpenAPI schema like:
 
@@ -358,9 +350,7 @@ The docs UI will interact with the server that you select.
 
 If you don't want **FastAPI** to include an automatic server using the `root_path`, you can use the parameter `root_path_in_servers=False`:
 
-```Python hl_lines="9"
-{!../../docs_src/behind_a_proxy/tutorial004.py!}
-```
+{* ../../docs_src/behind_a_proxy/tutorial004.py hl[9] *}
 
 and then it won't include it in the OpenAPI schema.