Working on: The Twitch authentication

This commit is contained in:
2025-12-25 21:05:11 +01:00
parent 773288faf0
commit e69d423deb
2 changed files with 12 additions and 5 deletions

View File

@@ -65,13 +65,13 @@ async def lifespan(app: FastAPI):
app = FastAPI(lifespan=lifespan)
# Add middleware to trust proxy headers (X-Forwarded-For, X-Forwarded-Proto)
# This is crucial for running behind a reverse proxy like Nginx or Caddy.
app.add_middleware(ProxyHeadersMiddleware, trusted_hosts="*")
# Add session middleware. A secret key is required for signing the session cookie.
# We can reuse our encryption key for this, but in production you might want a separate key.
# Note: Middleware is applied in reverse order (last added is first executed).
# We want ProxyHeaders to run FIRST (outermost) to fix the scheme/host,
# then SessionMiddleware to run SECOND (inner) so it sees the correct scheme.
app.add_middleware(SessionMiddleware, secret_key=settings.ENCRYPTION_KEY)
app.add_middleware(ProxyHeadersMiddleware, trusted_hosts="*")
# Mount the 'static' directory using an absolute path for reliability
# This MUST be done before the routes that depend on it are defined.