Update server.js with E6 syntax (#101)
server.js updates tested and validated here: https://boilerplate-express.johnsprunger.repl.co Co-authored-by: Muhammed Mustafa <MuhammedElruby@gmail.com>
This commit is contained in:
parent
fb45552535
commit
3d35745103
1 changed files with 9 additions and 9 deletions
18
server.js
18
server.js
|
@ -3,15 +3,15 @@
|
||||||
* the verification process may break
|
* the verification process may break
|
||||||
* ***************************************************/
|
* ***************************************************/
|
||||||
|
|
||||||
var bGround = require('fcc-express-bground');
|
const bGround = require('fcc-express-bground');
|
||||||
var myApp = require('./myApp');
|
const myApp = require('./myApp');
|
||||||
var express = require('express');
|
const express = require('express');
|
||||||
var app = express();
|
const app = express();
|
||||||
|
|
||||||
if (!process.env.DISABLE_XORIGIN) {
|
if (!process.env.DISABLE_XORIGIN) {
|
||||||
app.use(function(req, res, next) {
|
app.use((req, res, next) => {
|
||||||
var allowedOrigins = ['https://narrow-plane.gomix.me', 'https://www.freecodecamp.com'];
|
const allowedOrigins = ['https://narrow-plane.gomix.me', 'https://www.freecodecamp.com'];
|
||||||
var origin = req.headers.origin || '*';
|
const origin = req.headers.origin || '*';
|
||||||
if(!process.env.XORIG_RESTRICT || allowedOrigins.indexOf(origin) > -1){
|
if(!process.env.XORIG_RESTRICT || allowedOrigins.indexOf(origin) > -1){
|
||||||
console.log(origin);
|
console.log(origin);
|
||||||
res.setHeader('Access-Control-Allow-Origin', origin);
|
res.setHeader('Access-Control-Allow-Origin', origin);
|
||||||
|
@ -21,8 +21,8 @@ if (!process.env.DISABLE_XORIGIN) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
var port = process.env.PORT || 3000;
|
const port = process.env.PORT || 3000;
|
||||||
bGround.setupBackgroundApp(app, myApp, __dirname).listen(port, function(){
|
bGround.setupBackgroundApp(app, myApp, __dirname).listen(port, () => {
|
||||||
bGround.log(`Node is listening on port ${port}...`);
|
bGround.log(`Node is listening on port ${port}...`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue