Fix: Disable TrustedHostMiddleware behind Traefik proxy
TrustedHostMiddleware was blocking localhost healthchecks from Traefik, causing 400 Bad Request errors. When behind a reverse proxy like Traefik/Coolify, host validation is handled by the proxy itself.
This commit is contained in:
@@ -100,12 +100,14 @@ app.mount("/static", StaticFiles(directory=ADMIN_PANEL_DIR), name="static")
|
||||
templates = Jinja2Templates(directory=ADMIN_PANEL_DIR)
|
||||
|
||||
# Add middleware for production readiness
|
||||
if AppConfig.ENVIRONMENT == "production":
|
||||
# Trusted host middleware for production security
|
||||
app.add_middleware(
|
||||
TrustedHostMiddleware,
|
||||
allowed_hosts=AppConfig.TRUSTED_HOSTS
|
||||
)
|
||||
# NOTE: TrustedHostMiddleware disabled when behind reverse proxy (Traefik/Coolify)
|
||||
# The reverse proxy handles host validation
|
||||
# if AppConfig.ENVIRONMENT == "production":
|
||||
# # Trusted host middleware for production security
|
||||
# app.add_middleware(
|
||||
# TrustedHostMiddleware,
|
||||
# allowed_hosts=AppConfig.TRUSTED_HOSTS
|
||||
# )
|
||||
|
||||
# CORS middleware for cross-origin requests
|
||||
app.add_middleware(
|
||||
|
||||
Reference in New Issue
Block a user