aws / aws/serverless-application-model
API Property for Handle 404 and Handle 405
- Dominant language
- Python
- Stars
- 9.6k
- Forks
- 2.5k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 7
Description
API Gateway default behavior is to return a 403 - Forbidden response with a message of 'Missing Authentication Token' instead of a 404 - Not Found when the wrong resource path is provided and the same response instead of a 405 - Method Not Allowed when the wrong method is provided. Apparently this is by design, but is not desirable for many APIs.
I have developed a way to handle these situations to actually return a 404 and 405 where appropriate. I do this by using a `/{proxy+}` resource on the root of my API with a Lambda Proxy integration to Lambda that simply returns a 404 response. Similarly, on each of my defined paths I add an `ANY` method with a Lambda Proxy integration to a Lambda that simply returns a 405.
I currently do this using a swagger definition, but it gets quite verbose. I'm considering submitting a PR to SAM to add this capability to the transform similar to how the `Cors` property works on an `AWS::Serverless::API`.
Would anyone else be interested in this capability? Would this be an acceptable feature addition to the SAM transform?
Contributor guide
Assessment
This issue has not been assessed yet.