Skip to content

Instantly share code, notes, and snippets.

@eads
Created March 28, 2020 20:03
Show Gist options
  • Save eads/47374508d4207099b4e918fec7e4f79f to your computer and use it in GitHub Desktop.
Save eads/47374508d4207099b4e918fec7e4f79f to your computer and use it in GitHub Desktop.
'use strict';
module.exports.addCors = async (event, context, callback) => {
const response = event.Records[0].cf.response;
const headers = response.headers;
response.statusCode = 200;
headers['x-serverless-time'] = [{ key: 'x-serverless-time', value: Date.now().toString() }];
headers['access-control-allow-origin'] = [{ key:'access-control-allow-origin', value: '*' }];
delete headers['cache-control'];
delete headers['location'];
delete headers['expires'];
delete headers['server'];
return callback(null, response);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment