Setting http response header from AWS lambda

If you have Lambda proxy integration enabled, you can set the response headers as part of Lambda output and API Gateway will return them as part of the HTTP response to the client.

Node.js example:

callback(null, {
    "isBase64Encoded": false, // Set to `true` for binary support.
    "statusCode": 200,
    "headers": {
        "header1Name": "header1Value",
        "header2Name": "header2Value",
    },
    "body": "...",
});

where headers can be null or unspecified if no extra response headers are to be returned.

See Output Format of a Lambda Function for Proxy Integration.


and, if you DON'T have Lamba proxy integration enabled, you can add (and map) the response headers in the amazon API gateway console:

go to resources -> method execution -> method response -> add 'Access-Control-Allow-Origin' (or whatever) header for http status 200. Then go back to method execution -> integration response -> http status 200 -> set header mapping for 'Access-Control-Allow-Origin' to '*' (or whatever).

Solved this error...: "No 'Access-Control-Allow-Origin' header is present on the requested resource"