restrict CORS to env defined origin

This commit is contained in:
Sorrel Bri 2020-01-07 13:43:20 -08:00
parent 1b642eea2d
commit da1dc694f3
3 changed files with 10 additions and 1 deletions

View file

@ -269,6 +269,11 @@
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
"integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
},
"dotenv": {
"version": "8.2.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz",
"integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw=="
},
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",

View file

@ -11,6 +11,7 @@
"cookie-parser": "~1.4.4",
"cors": "^2.8.5",
"debug": "~2.6.9",
"dotenv": "^8.2.0",
"express": "~4.16.1",
"http-errors": "~1.6.3",
"morgan": "~1.9.1",

View file

@ -6,13 +6,16 @@ const path = require('path');
const cookieParser = require('cookie-parser');
const logger = require('morgan');
const dotenv = require('dotenv');
dotenv.config();
const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users');
const app = express();
const corsOptions = {
origin: '*'
origin: process.env.REACT_ADDRESS
}
app.options('*', cors(corsOptions));