AWS Lambda CORS
CORS Library for AWS Lambda with APIGateway.
Installation
npm install aws-lambda-cors --save
Usage
import { cors } from 'aws-lambda-cors'
const originLambdaHandler = async (event, ctx) => {
return {
statusCode: 200,
body: '',
})
}
// Also OK.
//
// const originLambdaHandler = (event, ctx, callback) => {
// callback(null, {
// statusCode: 200,
// body: '',
// })
// }
export const lambdaHandler = cors({
allowCredentials: true,
allowOrigins: [
'http://localhost:8000',
'https://wani.kr',
],
allowMethods: [
'OPTIONS',
'HEAD',
'GET',
'POST',
],
allowHeaders: [
'Authorization',
'Content-Type',
],
allowCredentials: true,
})(originLambdaHandler)