restify-cors-middleware/README.md
2017-05-23 08:28:29 +10:00

1.7 KiB

restify-cors-middleware

CORS middleware with full W3C spec support.

NPM License

Build Status Dependencies Dev dependencies Peer dependencies Known Vulnerabilities

JavaScript Style Guide

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.