Skip to content

Commit

Permalink
Force SSL
Browse files Browse the repository at this point in the history
  • Loading branch information
ebidel committed Oct 30, 2017
1 parent 0053f78 commit d7f3c9e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions server.js
Expand Up @@ -19,6 +19,14 @@
const express = require('express');

const app = express();

app.use(function forceSSL(req, res, next) {
if (req.hostname !== 'localhost' && req.get('X-Forwarded-Proto') === 'http') {
res.redirect(`https://${req.hostname}${req.url}`);
}
next();
});

app.use(express.static('public', {extensions: ['html', 'htm']}));
app.use(express.static('node_modules'));
// app.use(bodyParser.urlencoded({extended: true}));
Expand Down

0 comments on commit d7f3c9e

Please sign in to comment.