diff --git a/server.js b/server.js index 6a0120f..4ca6394 100644 --- a/server.js +++ b/server.js @@ -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}));