Created
March 28, 2020 20:03
-
-
Save eads/47374508d4207099b4e918fec7e4f79f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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