diff options
author | 2024-08-19 04:30:59 +0100 | |
---|---|---|
committer | 2024-08-19 04:30:59 +0100 | |
commit | 79b00e3bdc0603b038d30e70ab759c9ceeb8935a (patch) | |
tree | a768b94d4aecacd9039df3db9e539c5382df92a8 | |
parent | Add connect-src 'self' to allow try-it in Scalar to work (diff) |
Respect X-Forwarded-Proto for building URLs
-rw-r--r-- | thallium-backend/src/app.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/thallium-backend/src/app.py b/thallium-backend/src/app.py index 98a0500..15495d2 100644 --- a/thallium-backend/src/app.py +++ b/thallium-backend/src/app.py @@ -34,7 +34,9 @@ def health_check() -> JSONResponse: def build_url(request: Request, path: str = "") -> str: """Build a URL from a request, for OpenAPI + Scalar.""" - return f"{request.url.scheme}://{request.headers['Host']}{CONFIG.app_prefix}{path}" + scheme = request.headers.get("x-forwarded-proto", request.url.scheme) + + return f"{scheme}://{request.headers['Host']}{CONFIG.app_prefix}{path}" @fastapi_app.get("/docs", include_in_schema=False) |