generated from hjess/PythonTemplateProject
added middelware
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 37s
All checks were successful
Build, Push, and Deploy to Nomad / docker-nomad (push) Successful in 37s
This commit is contained in:
3
app.py
3
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")
|
||||
|
||||
Reference in New Issue
Block a user