diff --git a/index.js b/index.js index 37e952a0a..71744c8cf 100644 --- a/index.js +++ b/index.js @@ -26,6 +26,16 @@ app.use(express.static(path.join(__dirname, 'public'))); if ('development' === process.env.NODE_ENV) { app.use(errorhandler()); } +else { // production only + // handle https redirect + function ensureSecure(req, res, next){ + if(req.secure){ + // OK, continue + return next(); + }; + res.redirect('https://' + req.hostname + req.url); + } + app.all('*', ensureSecure); } app.get('/', routes.index); diff --git a/package.json b/package.json index 7897ca2b2..d5be3221b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "publicbodies", - "version": "0.1.0", + "version": "0.1.1", "description": "A database of public bodies such as government departments, ministries etc.", "main": "site/make.js", "directories": {