serverless-default-error-responses
Serverless plugin that adds unified API Gateway responses for error states. It adds CORS headers to all 4xx and 5xx API responses and formats output for users like this:
{
"errorMessage": "Application Error",
"errorCode": 500,
"apiRequestId": "2e2819fa-c93c-11e7-a46f-91ce8f8df51e"
}
It hides real error reason in case of 5xx errors and replaces it for Application Error
. It also adds API Gateway request id for potential further investigation in CloudWatch logs.
Installation
- Install npm package:
yarn add @keboola/serverless-default-error-responses --dev
- Add plugin to your
serverless.yml
:
plugins:
- '@keboola/serverless-default-error-responses'