1.0.1 • Published 7 years ago

lambda-cors v1.0.1

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
7 years ago

lambda-cors

Installation

npm install lambda-cors

Usage

In AWS API Gateway, it could ONLY set one origin for CORS.

To allow multiple origins, we could delay the CORS check to lambda execution.

This library adds the CORS headers automatically to the response.

var CORS = require("lambda-cors");

var cors = CORS({
    origins: ["http://domain1.com", "http://domain2.com"];
})

exports.handler = cors(function(event, context, callback) {
    // ... your request handler

    var res = { statusCode: 200, body: "Hello" };
    callback(null, res);
});