Skip to content

Instantly share code, notes, and snippets.

@maruware
Created April 27, 2018 03:11
Show Gist options
  • Save maruware/21370753be383e2a0eec7c5d4958b5b8 to your computer and use it in GitHub Desktop.
Save maruware/21370753be383e2a0eec7c5d4958b5b8 to your computer and use it in GitHub Desktop.
Attach cors header on AWS Lambda (nodejs8.10)
module.exports = (response) => {
const {headers, ...rest} = response
return {
...rest,
headers: {
'Access-Control-Allow-Origin': '*',
...headers
}
}
}
const cors = require('./cors')
module.exports.hello = (event, context, callback) => {
const response = {
statusCode: 200,
body: JSON.stringify({
msg: 'hello, world!'
})
}
callback(null, cors(response))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment