TrustedHostMiddleware ignores port in Host header #1998
Unanswered
blipk
asked this question in
Potential Issue
Replies: 3 comments 12 replies
-
Hi @iudeen Why was this converted to a discussion? It's an actual issue. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Any reference on what other web frameworks do in this case? |
Beta Was this translation helpful? Give feedback.
9 replies
-
Is there any use case for actually checking the port? If not, this is probably just a DX issue; we could check that allowed hosts don't contain ports and either raise an exception, or remove the ports and log a warning. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Cross-post from an issue at fastapi/fastapi#5818 as I didn't realise it was starlette providing this underneath.
Using the provided example code and making a request from localhost:8000 I get an "Invalid host header" response, even though looking at dev tools in chrome the header is Host: localhost:8000
If I change to allowed_hosts=["localhost"] it works fine.
I understand it's a trusted host, and not a trusted port, but seems strange to me that it says invalid host header even though thats exactly what the browser is sending in the host header.
Also see comment by @jgould22
Beta Was this translation helpful? Give feedback.
All reactions