jordaneremieff / mangum

AWS Lambda support for ASGI applications
https://mangum.io/
MIT License
1.67k stars 119 forks source link

`Request.url` does not include the api_gateway_base_path #318

Open beck3905 opened 6 months ago

beck3905 commented 6 months ago

I am using Mangum in a Lambda handler behind an API Gateway with a custom domain name. When I instantiate Mangum I provide my base path mapping with the api_gateway_base_path parameter. Inside my handler I reference the Request.url property, but it does not provide the actual URL used for the request because it does not include the API Gateway base path value in the path.

Reading the FastAPI docs it seems that this is what the root_path scope property is supposed to be used for, but in the APIGateway handler class root_path gets set to "".

https://github.com/jordaneremieff/mangum/blob/main/mangum/handlers/api_gateway.py#L101

Would it make sense for the root_path to be set to the api_gateway_base_path value if it is provided?