Skip to content

Commit

Permalink
Respect X-Forwarded-Proto for building URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
jb3 committed Aug 19, 2024
1 parent f787db9 commit 79b00e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion thallium-backend/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 79b00e3

Please sign in to comment.