Skip to content

CORS for Node.js that does not allow wildcards for Subdomain attacks

Notifications You must be signed in to change notification settings

laynef/node-secure-cors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Secure CORS

Installation

npm i -S secure-cors

Why Secure CORS

/*
Use secure CORS because it gives errors when you use wild cards for origins.
Allowing any wild cards in your CORS allows you to use your server with any domain under that wildcard.
Be sure to specify the exact urls you need.
*/

const express = require('express');
const cors = require('secure-cors');

const app = express();

app.use(cors({
    origin: 'https://www.example.com' // never '*' or '*.example.com'
}));

app.listen(3000);

About

CORS for Node.js that does not allow wildcards for Subdomain attacks

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published