proxy handling of css
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
5
main.py
5
main.py
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user