aws-lambda-cors
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

AWS Lambda CORS

Build Downloads Version License
dependencies Status devDependencies Status

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)

Package Sidebar

Install

npm i aws-lambda-cors

Weekly Downloads

191

Version

0.0.2

License

MIT

Unpacked Size

40.5 kB

Total Files

11

Last publish

Collaborators

  • wan2land