-
-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FastAPI redirects to wrong host with Mangum #307
Comments
Notice that the workaround does not work with lambda function URLs. In my case what fixed it was making sure my api endpoints does not have trailing this results in a 307 redirect loop @app.get("/test/")
def test_endpoint(): this works @app.get("/test")
def test_endpoint(): |
I ran into a similar issue, but also sort of opposite. I am using API Gateway with custom domain names and Lambda Proxy integration. When I run Mangum I provide the I ended up using the |
FastAPI responds with an HTTP 307 Temporary Redirect due to a missing or additional trailing slash (depending on the route). When this happens, it uses the
Host
header.When using CloudFront instead of API Gateway's custom domains, the
Host
header is changed to[apiId].execute-api.[region].amazonaws.com
and the original host is stored in an additional headerx-original-host
.Combined, this causes requests to be redirected to an
execute-api
url instead of the intended host.Related issues on FastAPI:
Workaround
As a temporary workaround, consider adding a wrapper around Mangum's handler
The text was updated successfully, but these errors were encountered: