CORS middleware with full W3C spec support
Find a file
2017-05-22 16:39:28 +10:00
src Merged with https://github.com/restify/plugins/pull/10 2017-05-09 13:23:44 -07:00
test Merged with https://github.com/restify/plugins/pull/10 2017-05-09 13:23:44 -07:00
.gitignore First commit, supports 12/15 items of the spec 2014-05-08 12:16:17 +10:00
.npmignore Don't publish test code to npm (.npmignore) 2016-07-11 14:54:18 +10:00
.travis.yml chore: drop support for Node.js 0.10 2016-11-01 09:32:37 +11:00
package.json Merged with https://github.com/restify/plugins/pull/10 2017-05-09 13:23:44 -07:00
README.md Add peer deps badge 2016-09-07 14:25:30 +10:00

restify-cors-middleware

CORS middleware with full W3C spec support.

NPM License

Build Status Dependencies Dev dependencies Peer dependencies Known Vulnerabilities

Usage

var corsMiddleware = require('restify-cors-middleware');

var cors = corsMiddleware({
  preflightMaxAge: 5, //Optional
  origins: ['http://api.myapp.com', 'http://web.myapp.com'],
  allowHeaders: ['API-Token'],
  exposeHeaders: ['API-Token-Expiry']
});

server.pre(cors.preflight);
server.use(cors.actual);

Compliance to the spec

See unit tests for examples of preflight and actual requests.