-
Notifications
You must be signed in to change notification settings - Fork 52
Unexpected behaviour with API-Gateway Custom Domain Name Mapping #27
Comments
any update on this? even i am facing the same issue. |
Are you using a proxy integration? https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-api-as-simple-proxy-for-http.html If so, I did a pull-request that has been merged where you can specify the proxy path. This should work for custom domains as well. See #26 In api gateway the resource should be defined like this: This allows the route to be written without the base part, so we can write the route like this: |
Hi, Thanks for your reply. I've tested the new version of aws-lambda-router that includes your pull request just now. I've noticed that the thing you've achieved with your pull request differs from my issue. Lambda's are usually deployed to an url like Where However, if you supply a custom domain in API Gateway, there are three options.
The API is just the Lambda application. The path is probably what you are using in proxyPath: if you want https://example.com/v1/{proxy+} to all redirect to a certain lambda without the need to put Lastly, the Stage option, can be selected to make sure that https://api.example.com uses the prod stage whereas https://api-test.example.com uses the dev stage. This way the stage does not have to be supplied in the request url, like https://api-test.example.com/dev/{proxy+}. And while the stage is not supplied, aws-lambda-router's code still (wrongly) removes the first parameter from the request url, causing a mismatch with the routes. |
I did not understand this ugly hack and it has brought me a lot of headaches already. Couldn't we have a variable that disables this behavior? |
@gravitycode I'd love to see an option to disable it in a future version as well. |
I believe I'm running into the same or similar issue. I have an api gateway instance setup with a custom domain. my routes are: when I call https://custom-domain.com/api/events I'm hitting the lambda but it's returning the following error:
It seems like the router is removing the base /api? Or it's not getting passed through. Though I believe the issue is the former. When I add a base path mapping to my api gateway instance for /api then if I call: |
I've created a PR that implements your suggestion of having the ability to disable the removal of the base path. See here: #72 |
The PR #72 is closed now. To avoid the behaviour please use the following configuration of
|
Created a PR adding documentation for |
Hi,
Recently we found out that the first parameter from the
event.path
was ignored. After a quick inspectation of thelib/proxyIntegration.js
file, I found an "ugly hack" which caused this behaviour, along with the following comment:My guess is this function is necessary for cases where users of aws-lambda-router use the API-gateway like this: http://customdomain.com/[stage]/[...parameters] (i.e. using the stage in between the custom domain and the parameters). However, in my case only the
prod
stage should be published on the custom domain. That's why I created a base path mapping in my Custom Domain options which maps the/
path tomylambdafunctionname:prod
(theprod
stage of my API). This is why I don't have the stage name in my custom url and I think this is what causes the code to (in my case undesirable) remove the first parameter. But this is just my guess. I'm not entirely sure what is meant bybasepath
in the "ugly hack" comment, but regardless of whether it's because of me not having the stage in my custom url or it's because of something else, my point regarding unexpected first parameter removal still stands.I'd be glad to hear if more details are needed to debug this case.
The text was updated successfully, but these errors were encountered: