Search code examples
corsaws-lambdamicroservicesapi-gateway

Enable CORS on API Gateway + Lambda Microservice template + DynamoDB


I already enable CORS resource in the API Gateway, but it doesn't work


Solution

  • I added Access-Control-Allow-Origin headers in lamda function (nodejs).

    It works for me

    const done = (err, res) => callback(null, {
        statusCode: err ? '400' : '200',
        body: err ? err.message : JSON.stringify(res),
        headers: {
            'Content-Type': 'application/json', 
            'Access-Control-Allow-Origin': '*'
        }    
    });