Skip to content
This repository has been archived by the owner on Mar 17, 2020. It is now read-only.

miki79/middy-cors-extended

Repository files navigation

NPM version CircleCI Test Coverage Known Vulnerabilities

ATTENTION this package is not DEPRECATED as the extra CORS functionalities have been implemented in Middy

Middleware for Middy, extends the CORS middleware adding extra options.

Sets CORS headers (Access-Control-Allow-Origin, Access-Control-Allow-Headers and Access-Control-Allow-Credentials).

Sets headers in after and onError phases.

Options

  • origin (string) (optional): origin to put in the header (default: "*")
  • headers (string) (optional): comma list of headers to put in Access-Control-Allow-Headers (default: "Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent")
  • credentials (boolean) (optional): if true, set Access-Control-Allow-Credentials to true, and put Access-Control-Allow-Origin as the Origin request header.

Sample usage

const middy = require('middy');
const { cors } = require('middy/middlewares');

const handler = middy((event, context, callback) => {
  callback(null, {});
});

handler.use(cors({ origin: 'http://www.google.co.uk', credentials: true }));

About

Extends CORS middleware for middy

Resources

License

Stars

Watchers

Forks

Packages

No packages published