mirror of
https://github.com/fastapi/fastapi.git
synced 2026-03-31 13:11:17 -04:00
📝 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:
committed by
GitHub
parent
176cd8c9ef
commit
f5b77ff0fc
@@ -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"]
|
||||
Reference in New Issue
Block a user