restify-cors
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

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.

Package Sidebar

Install

npm i restify-cors

Weekly Downloads

4

Version

1.0.1

License

MIT

Last publish

Collaborators

  • manuelrauber