🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

cors-express

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
e

cors-express

Middleware to control CORS in an Express app

0.2.2
latest
92

Supply Chain Security

100

Vulnerability

66

Quality

88

Maintenance

100

License

Version published
Weekly downloads
31
-66.3%
Maintainers
1
Weekly downloads
 
Created
Issues
0

cors-express

Middleware to control CORS in an Express app

Installation

The best way to install it is using npm

npm install cors-express --save

Loading

var cors = require('cors-express');

Initialization and Usage

var app = express(),
    options = {};

app.use(cors(options));

Options

{
allow : {
    origin: '*',
    methods: 'GET,PATCH,PUT,POST,DELETE,HEAD,OPTIONS',
    headers: 'Content-Type, Authorization, Content-Length, X-Requested-With, X-HTTP-Method-Override'
},
expose :{
    headers : null
},
max : {
    age : null
},
options : function(req, res, next){
    if (req.method == 'OPTIONS') {
        res.status(200).end();
    } else {
        next();
    }
},
specials : {
    powered : null
}

Options

This method override the normal use of the "option" method and return OK with seted CORS headers

Specials

Powered

Can change the "x-powered-by" header. You can use:

  • null show original header: "Express"
  • false doesn't show the header: "Express
  • string show your own string

Support

This plugin is proudly supported by Kubide hi@kubide.es

Keywords

FAQs

Package last updated on 09 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts