proxy handling of css

This commit is contained in:
2025-11-18 00:55:32 +01:00
parent 4b96b17368
commit a0877d8276
2 changed files with 6 additions and 1 deletions

View File

@@ -29,7 +29,7 @@ class ListenerManager:
channel_name=user.username,
client_id=settings.TWITCH_CLIENT_ID,
client_secret=settings.TWITCH_CLIENT_SECRET,
bot_id=user.platform_user_id,
id=user.platform_user_id,
websocket_manager=websocket_manager,
db_user_id=user.id
)

View File

@@ -1,6 +1,7 @@
import os
import asyncio
from fastapi import FastAPI, Request, Depends, HTTPException
from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
from starlette.middleware.sessions import SessionMiddleware
from starlette.staticfiles import StaticFiles
from starlette.responses import FileResponse, RedirectResponse
@@ -59,6 +60,10 @@ 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.
app.add_middleware(SessionMiddleware, secret_key=settings.ENCRYPTION_KEY)