middy-cors-extended
v0.0.9
Published
Extends CORS middleware for middy
Maintainers
Readme
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 }));