From 0936adae7d52cc86c15f459ca60426fcff10b843 Mon Sep 17 00:00:00 2001 From: Henrik Jess Nielsen Date: Tue, 10 Dec 2024 21:48:34 +0100 Subject: [PATCH] added middelware --- app.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index f9fb6c1..e3f7840 100644 --- a/app.py +++ b/app.py @@ -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")