Skip to content

Lambda function triggered by API Gateway and Lambda tests, but not by POST request to API Gateway domain name.

0

I have a Lambda function that is set up to be triggered via API Gateway. When I test from AWS Lambda, the function executes correctly. When I test from API Gateway, the function executes just fine. However, when I attempt to post to the custom domain name I set up in API Gateway, I get a 500. Additionally, the function does not put any logs to CloudWatch, which leads me to believe it's not being invoked. I have a trigger set up with API Gateway to invoke the function, so I'm not sure why it's not being invoked. API Gateway Trigger API Gateway Test Lambda Test Error Message

1 Answer
0
Accepted Answer

Hi,

You have the explanations re. CORS issues (see you error message) and API Gateway in this page: see https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-cors.html

If it is a POST method request, it must include an Origin header.

So, you probably need to add this header in your request when you POST to the API Gateway,

This post shows how to configure CORS from console: https://medium.com/geekculture/simple-steps-to-enable-cors-in-api-gateway-through-console-cloud-formation-c09d9df31c07

Best,

Didier

EXPERT
answered 2 years ago
EXPERT
reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.