starlette
starlette copied to clipboard
TrustedHostMiddleware rejects requests from IPv6 hosts
When my app runs behind an IPv6 address and I configure TrustedHostMiddleware with allowed_hosts, requests coming from bracketed IPv6 hosts like [::1]:8000 get rejected with 400 Invalid host header even though the host is in the allowed list. It looks like the middleware does not parse the brackets/port for IPv6 correctly.
Thanks for the report — this is a duplicate of #3357. That issue already describes TrustedHostMiddleware rejecting bracketed IPv6 hosts/ports, so discussion and fixes are being tracked there.