aws-serverless-java-container: API Gateway Path Mapping Problem
- Framework version: 0.9
- Implementations: Jersey (but I believe this affects all versions)
Scenario
All the details of this issue can be found on this AWS Forums thread.
Basically, regular URLs and Custom Domain Name URLs From API Gateway, inconsistently map their URL paths to the invoked a Lambda Function.
Here’s my invocation logs, from bot a regular API Gateway URL and a Custom Domain Name URL:
Custom Domain Name URL:
"resource":"/{proxy+}","path":"/service/prod/test",
"Host":"api.myservice.com",
"pathParameters":{"proxy":"test"}
"path":"/service/prod/test",
"stage":"prod",
Regular URL:
"resource":"/{proxy+}","path":"/test",
"Host":"aaaaaaaaaaa.execute-api.us-east-1.amazonaws.com",
"pathParameters":{"proxy":"test"},
"path":"/prod/test",
"stage":"prod",
The same Lambda Function, invoked with both URLs will produce different resutls, since the path being passed is different, the Lambda Function invoked with:
https://aaaaaaaaaaa.execute-api.us-east-1.amazonaws.com/prod/test
will execute normaly, but the same Lambda Function invoked with:
https://api.myservice.com/service/prod/test
will return 404 since the path being passed to Jersey by this framework will be an invalid one.
Expected behavior
Calling both APIs will invoke the Lambda Function consistently with the same path and both will execute on the same way.
Actual behavior
https://aaaaaaaaaaa.execute-api.us-east-1.amazonaws.com/prod/test
will execute normaly, but the same Lambda Function invoked with:
https://api.myservice.com/service/prod/test
will return 404 since the path being passed to Jersey by this framework will be an invalid one.
Steps to reproduce
1 - Create a new API Gateway {proxy+} method that invokes a Lambda Function running Jersey
2 - Create a Custom Domain Name and a basepath mapping for that Lambda Function
3 - Invoke the API using both URLs
From the logs:
Custom Domain Name URL:
"resource":"/{proxy+}","path":"/service/prod/test",
"Host":"api.myservice.com",
"pathParameters":{"proxy":"test"}
"path":"/service/prod/test",
"stage":"prod",
Regular URL:
"resource":"/{proxy+}","path":"/test",
"Host":"aaaaaaaaaaa.execute-api.us-east-1.amazonaws.com",
"pathParameters":{"proxy":"test"},
"path":"/prod/test",
"stage":"prod",
I can see the pathParameters are the same on both cases, but the path is different.
Is this library using the path and this is the source of the problem? Could it change to using the pathParameters instead?
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (11 by maintainers)
Commits related to this issue
- Fixes to address Jersey routing issue reported in #112. This is a new bug introduced with the fixes for #84. Added unit tests — committed to awslabs/aws-serverless-java-container by sapessi 6 years ago
- Merge pull request #113 from awslabs/jersey Fix routing issue with Jersey when stripBasePath is configured (addresses #112) — committed to awslabs/aws-serverless-java-container by sapessi 6 years ago
@SAPessi it works perfectly now! I will probably make some sort of configuration file to provide the URL to be stripped out, since there are
prodanddevURLs for the same Lambda Function.Thank you for all the help, you are the best!
thanks. Ping here if you think there’s something wrong