-
Notifications
You must be signed in to change notification settings - Fork 4k
/
server.js
33 lines (28 loc) · 1.16 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/******************************************************
* PLEASE DO NOT EDIT THIS FILE
* the verification process may break
* ***************************************************/
const bGround = require('fcc-express-bground');
const myApp = require('./myApp');
const express = require('express');
const app = express();
if (!process.env.DISABLE_XORIGIN) {
app.use((req, res, next) => {
const allowedOrigins = ['https://narrow-plane.gomix.me', 'https://www.freecodecamp.com'];
const origin = req.headers.origin || '*';
if(!process.env.XORIG_RESTRICT || allowedOrigins.indexOf(origin) > -1){
console.log(origin);
res.setHeader('Access-Control-Allow-Origin', origin);
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
}
next();
});
}
const port = process.env.PORT || 3000;
bGround.setupBackgroundApp(app, myApp, __dirname).listen(port, () => {
bGround.log(`Node is listening on port ${port}...`);
});
/******************************************************
* PLEASE DO NOT EDIT THIS FILE
* the verification process may break
* ***************************************************/