1.0.1 • Published 8 years ago

restify-cors v1.0.1

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

restify-cors

CORS middleware with full W3C spec support.

NPM License

Build Status Dependencies Dev dependencies Peer dependencies

This project has been forked from https://github.com/TabDigital/restify-cors-middleware.

Changes

  • Supports restify 4.2
  • Usage with TypeScript

Usage

var restifyCors = require('restify-cors');

var cors = restifyCors({
  preflightMaxAge: 5, // Optional
  origins: ['http://api.myapp.com', 'http://web.myapp.com'], // defaults to ['*'] to allow all origins
  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.