You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently HTTPSRedirectMiddleware redirects to the same port as what HTTP is served from. That'd be great if the redirection target port could be given as an optional parameter.
For example when I run an application with the following configuration:
When I go to http://localhost:80 the application tries to redirect me to https://localhost:80.
There are two workarounds:
implement your own HTTPSRedirectMiddleware which does handle that logic
use hypercorn's HTTPToHTTPSRedirectMiddleware, as described in their docs, which is not ideal as it's HTTP server specific (if I wanted to switch to some other server, I'd have to change the application code):
fromhypercorn.middlewareimportHTTPToHTTPSRedirectMiddleware# ... as above but with `HTTPSRedirectMiddleware` removed.starlette_app=Starlette(routes=routes, debug=True)
app=HTTPToHTTPSRedirectMiddleware(starlette_app, host="localhost:8000")
I'd be happy to fill in a PR as long as that idea sounds reasonable to others : )
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Currently HTTPSRedirectMiddleware redirects to the same port as what HTTP is served from. That'd be great if the redirection target port could be given as an optional parameter.
For example when I run an application with the following configuration:
And I run it on
hypercorn
like this:When I go to
http://localhost:80
the application tries to redirect me tohttps://localhost:80
.There are two workarounds:
HTTPSRedirectMiddleware
which does handle that logicI'd be happy to fill in a PR as long as that idea sounds reasonable to others : )
Beta Was this translation helpful? Give feedback.
All reactions