From c82c60a5624430e5fa11c44a18ae2a9e6f7c7892 Mon Sep 17 00:00:00 2001 From: poduck Date: Mon, 1 Dec 2025 19:14:25 -0500 Subject: [PATCH] fix(traefik): Add host rewriting for email autoconfig endpoints MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Django's multi-tenant middleware doesn't recognize autoconfig/autodiscover subdomains. This middleware rewrites the Host header to api.smoothschedule.com so Django routes the request to the public schema. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- smoothschedule/compose/production/traefik/traefik.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/smoothschedule/compose/production/traefik/traefik.yml b/smoothschedule/compose/production/traefik/traefik.yml index f90bbf8..5b71e7a 100644 --- a/smoothschedule/compose/production/traefik/traefik.yml +++ b/smoothschedule/compose/production/traefik/traefik.yml @@ -64,10 +64,13 @@ http: certResolver: letsencrypt # Email autoconfiguration subdomains + # These need host rewriting because Django's tenant middleware doesn't recognize them autoconfig-router: rule: 'Host(`autoconfig.smoothschedule.com`)' entryPoints: - web-secure + middlewares: + - email-autoconfig-host service: django tls: certResolver: letsencrypt @@ -76,6 +79,8 @@ http: rule: 'Host(`autodiscover.smoothschedule.com`)' entryPoints: - web-secure + middlewares: + - email-autoconfig-host service: django tls: certResolver: letsencrypt @@ -107,6 +112,12 @@ http: headers: hostsProxyHeaders: ['X-CSRFToken'] + email-autoconfig-host: + # Rewrite Host header so Django tenant middleware routes to API/public schema + headers: + customRequestHeaders: + Host: 'api.smoothschedule.com' + services: django: loadBalancer: