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

cors-express2

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cors-express2

Express middleware to enable cross origin resource sharing on a route

1.0.0
latest
Source
npm
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

CORS middleware

A simple Express middleware to enable cross origin resource sharing on a route. It will deals with access-control-allow-origin, access-control-allow-credentials, access-control-request-headers and access-control-allow-methods headers. OPTIONS preflight requests will be directly answered with a HTTP 200 - OK.

Usage

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

var app = Express();

express.use(cors({
    allowWithoutOrigin: true,
    onlyAllowedOrigin: true,
    allowCredentials: true,
	allowedOrigins: [
		'http://127.0.0.1:8181',
		'http://localhost:8181'
	],
	nullOrigin: 'null'
}));

Options

  • allowWithoutOrigin: if true, allow requests without origin, setting access-control-allow-origin=*
  • onlyAllowedOrigin: if true, requires the origin to be in the list of allowed origins
  • allowCredentials: if true, will set access-control-allow-credentials=true
  • allowedOrigins: an array of string representing the allowed origins
  • nullOrigin: set the string corresponding to null origin, most likely the default will always be ok

FAQs

Package last updated on 06 Aug 2019

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