2
votes

For now, I haven't set any error handling in api gateway to catch the lambda error.
Every when api error occurs, the error will only show as CORS problem in console from browser inspecter.

I can only see the error if I use Postman to send api, but cannot view the error in Browser inspecter.

It seems it can achieve by Lambda error regex, but it needs to uncheck the "use lambda proxy integration" in api gateway.

Is there any way to achieve it without unchecking the checkbox of "use lambda proxy integration"

1
Please check if the link below helps you in any way: docs.aws.amazon.com/apigateway/latest/developerguide/…Azize

1 Answers

1
votes

There is no such way. The use of proxy lambda integration means that everything is handled by your lambda function, including returning error messages and error codes:

The integrated Lambda function verifies all of the input sources before processing the request and responding to the client with meaningful error messages if any of the required input is missing.

Further clarified here:

For a proxy integration, API Gateway automatically passes the backend output to the client as an HTTP response. You do not set either an integration response or a method response.

If you want to off-load error processing from lambda function to API Gateway, then you have to use Lambda custom integrations. This will allow you, as you already observed, modifications to integration response.