CORS middleware with full W3C spec support
Find a file
2016-09-07 14:12:43 +10:00
src Add option to specify the preflight max age 2014-10-10 18:14:36 +11:00
test Add option to specify the preflight max age 2014-10-10 18:14:36 +11: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 Updates restify peerDependency to 4.x 2015-12-01 17:38:10 +11:00
package.json chore(package): update dependencies 2016-09-07 14:12:43 +10:00
README.md Missing comma. 2014-12-03 14:54:59 +00:00

restify-cors-middleware

CORS middleware with full W3C spec support.

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.