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)
|
templates = Jinja2Templates(directory=ADMIN_PANEL_DIR)
|
||||||
|
|
||||||
# Add middleware for production readiness
|
# Add middleware for production readiness
|
||||||
if AppConfig.ENVIRONMENT == "production":
|
# NOTE: TrustedHostMiddleware disabled when behind reverse proxy (Traefik/Coolify)
|
||||||
# Trusted host middleware for production security
|
# The reverse proxy handles host validation
|
||||||
app.add_middleware(
|
# if AppConfig.ENVIRONMENT == "production":
|
||||||
TrustedHostMiddleware,
|
# # Trusted host middleware for production security
|
||||||
allowed_hosts=AppConfig.TRUSTED_HOSTS
|
# app.add_middleware(
|
||||||
)
|
# TrustedHostMiddleware,
|
||||||
|
# allowed_hosts=AppConfig.TRUSTED_HOSTS
|
||||||
|
# )
|
||||||
|
|
||||||
# CORS middleware for cross-origin requests
|
# CORS middleware for cross-origin requests
|
||||||
app.add_middleware(
|
app.add_middleware(
|
||||||
|
|||||||
Reference in New Issue
Block a user