forked from bmorelli25/React-Weather-App
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
20 lines (19 loc) · 633 Bytes
/
Copy pathserver.js
File metadata and controls
20 lines (19 loc) · 633 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var express = require('express');
//Create our App
var app = express();
//set enviornment variable, if there isn't one (aka locally) use 3000
const PORT = process.env.PORT || 3000;
//reroute all https traffic to http using express midleware
app.use(function (req, res, next) {
if (req.headers['x-forwarded-proto'] === 'https') {
res.redirect('http://' + req.hostname + req.url);
} else {
next(); //lets request process as normal
}
});
//tell it which folder we want to serve
app.use(express.static('public'));
//start the server
app.listen(PORT, function() {
console.log('Express Server is up on port ' + PORT);
});