restify-cors
v1.0.1
Published
Common middlewares for all Node.js web services
Downloads
7
Maintainers
Readme
restify-cors
CORS middleware with full W3C spec support.
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.