Socket
Book a DemoInstallSign in
Socket

cors-express

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cors-express

Middleware to control CORS in an Express app

latest
Source
npmnpm
Version
0.2.2
Version published
Weekly downloads
49
-22.22%
Maintainers
1
Weekly downloads
 
Created
Source

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

cors

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