Skip to content

Instantly share code, notes, and snippets.

@khaledosman
Created August 23, 2018 11:28
Show Gist options
  • Save khaledosman/17ebf8b67f8eca1c790eb726805b8438 to your computer and use it in GitHub Desktop.
Save khaledosman/17ebf8b67f8eca1c790eb726805b8438 to your computer and use it in GitHub Desktop.
aws lambda response w/ cors enabled for serverless
export function lambdaResponse (body: any, statusCode = 200): any {
return {
body: JSON.stringify(body),
headers: {
'Access-Control-Allow-Credentials': true,
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Origin': '*'
},
statusCode,
isBase64Encoded: false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment