CORS AND API GATEWAY LAMBDA PROXY INTEGRATION

Enabling CORS

Advertisements

To enable CORS when creating a Lambda Proxy Integration API, you must add the following code to the LAMBDA function:

headers: {
“Access-Control-Allow-Origin” : “*” // Required for CORS support to work
}

So an example payload might be:

var response = {
statusCode: 200,
headers: {
“Access-Control-Allow-Origin” : “*” // Required for CORS support to work
},
body: JSON.stringify({
payload: “My payload”
})
};

This took me a lot searching to find! This certainly helped:┬áservless.com/…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s