I currently have a Lambda function that works when I test it (it is a Mailchimp integration for subscribing a user to a list).
See my lambda function here on Github
I made an API endpoint using API gateway through lambda.
However, when I am testing it on my app (currently through localhost:3000, I am getting a CORS error from API gateway:
Access to XMLHttpRequest at 'https://MY_API.execute-api.us-west-2.amazonaws.com/default/mailchimp-lambda' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I have tried multiple things:
- Adding the npm package middy as recommended on https://serverless.com/blog/cors-api-gateway-survival-guide/
- Using a callback in lambda and adding CORS as recommended on this question: Configure CORS response headers on AWS Lambda?
Can anyone explain how to access a lambda function?