📝 Add documentation for Behind a Proxy - Proxy Forwarded Headers, using --forwarded-allow-ips="*" (#14028)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Sebastián Ramírezandpre-commit-ci[bot] authored and GitHub committed 2025-08-31 21:34:08 +02:00
1 parent 176cd8c9ef
commit f5b77ff0fc
4 files changed
+164 -6

No files matched your search

@@ -0,0 +1,21 @@
from fastapi.testclient import TestClient
from docs_src.behind_a_proxy.tutorial001_01 import app
client = TestClient(
app,
base_url="https://example.com",
follow_redirects=False,
)
def test_redirect() -> None:
response = client.get("/items")
assert response.status_code == 307
assert response.headers["location"] == "https://example.com/items/"
def test_no_redirect() -> None:
response = client.get("/items/")
assert response.status_code == 200
assert response.json() == ["plumbus", "portal gun"]