Skip to content

Commit

Permalink
Update server.js with E6 syntax (#101)
Browse files Browse the repository at this point in the history
server.js updates tested and validated here: https://boilerplate-express.johnsprunger.repl.co

Co-authored-by: Muhammed Mustafa <MuhammedElruby@gmail.com>
  • Loading branch information
JohnSprunger and Sboonny committed May 22, 2023
1 parent fb45552 commit 3d35745
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* the verification process may break
* ***************************************************/

var bGround = require('fcc-express-bground');
var myApp = require('./myApp');
var express = require('express');
var app = express();
const bGround = require('fcc-express-bground');
const myApp = require('./myApp');
const express = require('express');
const app = express();

if (!process.env.DISABLE_XORIGIN) {
app.use(function(req, res, next) {
var allowedOrigins = ['https://narrow-plane.gomix.me', 'https://www.freecodecamp.com'];
var origin = req.headers.origin || '*';
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);
Expand All @@ -21,8 +21,8 @@ if (!process.env.DISABLE_XORIGIN) {
});
}

var port = process.env.PORT || 3000;
bGround.setupBackgroundApp(app, myApp, __dirname).listen(port, function(){
const port = process.env.PORT || 3000;
bGround.setupBackgroundApp(app, myApp, __dirname).listen(port, () => {
bGround.log(`Node is listening on port ${port}...`);
});

Expand Down

0 comments on commit 3d35745

Please sign in to comment.