added middelware
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 37s

This commit is contained in:
2024-12-10 21:48:34 +01:00
parent d9001d2758
commit 0936adae7d

3
app.py
View File

@@ -9,6 +9,7 @@ from starlette.middleware.httpsredirect import HTTPSRedirectMiddleware
from fastapi import FastAPI
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.requests import Request
from fastapi.middleware.trustedhost import TrustedHostMiddleware
class ProxyHeadersMiddleware(BaseHTTPMiddleware):
async def dispatch(self, request: Request, call_next):
@@ -28,7 +29,7 @@ app = FastAPI()
# Mount static files
app.mount("/static", StaticFiles(directory="static"), name="static")
app.add_middleware(ProxyHeadersMiddleware)
app.add_middleware(TrustedHostMiddleware, allowed_hosts=["lifefaq.nomad.i80.dk", "localhost"])
# Templates directory
templates = Jinja2Templates(directory="templates")