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:
richardtekula
2025-11-11 16:41:43 +01:00
parent 6d0ee923e2
commit f9c80c375a

View File

@@ -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(