I'm using the Serverless framework to create an API. Endpoints are defined in the serverless.yml file, creating API Gateway endpoints that route through a custom Authorizer function and resolve to Go Lambda functions.
However, if a client hits an endpoint that has not been explicitly defined, passing in their JWT Token in the Authorization header, API Gateway returns a 403 Forbidden response with the following body:
{
"message": "'{{JWT TOKEN}}' not a valid key=value pair (missing equal-sign) in Authorization header: 'Bearer {{JWT TOKEN}}'"
}
The 403 Forbidden status seems appropriate, but I'd like to send an easier to understand error message back to my clients in the body of the response.
Is there a way to modify the response body when an invalid endpoint is requested?