CORS middleware with full W3C spec support
Find a file
Chris Nguyen 1454782381 Merge pull request #3 from TabDigital/Max-age-support
Add option to specify the preflight max age
2014-10-14 08:30:00 +11: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
package.json 0.0.3 2014-06-25 10:56:34 +10:00
README.md Add option to specify the preflight max age 2014-10-10 18:14:36 +11: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.