AWS API Gateway - 403 error on resource not found
The answer seems to be HTTP
403
accepted as the norm and properly handle any calls made to a resource or endpoint that does not exist in the API gateway setup ( this post ).
Example: Calling a non-existent endpoint on my gateway would be:
- GET - https: // {{MyGatewayDomain}} / api / v1 / blah
This will return a 403 forbidden
. Which can be quite confusing and misleading.
I would like to know if anyone has succeeded in configuring their API gateway so that any call to a non-existent endpoint / resource will return what I would consider to be the correct 404 response?
Thanks in advance.
EDIT
As per the suggestion, bejos-aws
I can override the default behavior 403 Missing Authentication Token
, however this will not solve my problem, since then all valid errors 403
will return an answer 404
that is incorrect.
Also, my issue concerns 403 forbidden
which does not exist in the default answers in the AWS list Gateway Response
(and even if it did, it didn't help).
Seems like it's just not possible?
source to share
This is currently a feature of API Gateway. However, there is a workaround. Using the gateway response, you can override the response 403 Missing Authentication Token
with 404
and specify any message you want as the response.
Please note: this only works on API action :
So, if your API is deployed in a stage named v1
https://{MyGatewayDomain}/api/v1/somepath
And the caller supplies the wrong stage
https://{MyGatewayDomain}/api/invalidStage/somepath
Then the API will still respond 403 Forbidden
source to share