Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/laynef/node-secure-cors

CORS for Node.js that does not allow wildcards for Subdomain attacks
https://github.com/laynef/node-secure-cors

cors security subdomains

Last synced: 15 days ago
JSON representation

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

Awesome Lists containing this project

README

        

# 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);