#636 — Domain Detection Middleware
Repo: Twill-AI/facade State: closed | Status: done Assignee: meliascosta
Created: 2025-10-08 · Updated: 2025-10-22
Description
Create FastAPI middleware to detect partner from incoming request hostname and inject whitelabel configuration into request state for use by downstream handlers. Ensure middleware runs before authentication.
AC:
-
Middleware extracts hostname from
request.headers.get('host') -
Queries
partner_domaintable for matching verified domain -
Loads
partner_whitelabel_configif partner found -
Injects
request.state.partner_idandrequest.state.whitelabel_config -
Handles missing/invalid domains gracefully (Falls back to
my.twillai.com, default Twill branding) -
Middleware registered in
app/main.pybefore route handlers -
Unit tests cover domain matching logic
Notes
Add implementation notes, blockers, and context here
Related
Add wikilinks to related people, meetings, or other tickets