I\'m stuck on an issue with API gateway and I\'ve gone through all the other SO answers on this, AWS forums and have been through their docs but still no joy.
I am t
In case you want to change only one header instead of replacing all headers as is shown in Words Like Jared answer. You can use this code:
'use strict';
module.exports.handler = (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
headers['access-control-allow-origin'] = [{ key: 'Access-Control-Allow-Origin', value: "*" }];
return callback(null, response);
};
Another examples can be found on Adding HTTP Security Headers Using Lambda@Edge and Amazon CloudFront. It works same for normal Lambda function.