mirror of
https://github.com/reconurge/flowsint.git
synced 2026-05-07 04:09:49 -05:00
[GH-ISSUE #124] feat(deploy): Proposals and best practices #771
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @gustavorps on GitHub (Feb 17, 2026).
Original GitHub issue: https://github.com/reconurge/flowsint/issues/124
Context
When deploying FastAPI behind a reverse proxy (e.g., NGINX, Traefik, Caddy), several issues commonly arise:
httpinstead ofhttps)Reference: Official docs "Behind a Proxy - FastAPI"
Proposals
Disable Automatic Redirect Slashes
Proposal
Why
FastAPI (via Starlette) automatically redirects:
/endpoint→/endpoint//endpoint/→/endpointBehind a proxy, this can cause:
Benefits
Best Practice
Be explicit in route definitions:
and ensure frontend uses exact paths on the clients SDK.
Proper Proxy Header Handling (CRITICAL)
Disabling redirect slashes alone is not enough.
Ensure proxy headers are trusted:
Run with:
or (if using uvicorn directly):
Why
Without this:
request.url.schememay be wronghttpThis is mandatory behind TLS termination.
Adopt
fastapi runOveruvicornProposal
Standardize on:
over:
Why
fastapi run:Recommendation
fastapi devfor developmentfastapi runfor productionSet Proper Referrer Policy
Proposal
Add response header:
(or if you truly need same-origin only)
Recommended Value
strict-origin-when-cross-originWhy
It:
Reverse Proxy Configuration
NGINX Example
Without these:
Set
root_pathIf Behind SubpathIf your app is served at:
https://example.com/apiUse:
Or configure via proxy properly.
Otherwise:
Recommended Deployment Baseline
FastAPI App
Run Command
Proxy Must Set
X-Forwarded-ProtoX-Forwarded-ForHostSecurity Headers
@dextmorgn commented on GitHub (Feb 23, 2026):
Hey @gustavorps,
Thanks a lot for your work. I'll spend some time in the next day to review your PR.
I'll let you know :)