0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-27 00:42:40 +00:00

Added middleware to force all routes to be https

This commit is contained in:
Scott Tolksdorf
2018-11-30 16:29:05 -05:00
parent 448ea5cf5c
commit 21b83ead88
2 changed files with 9 additions and 1 deletions

7
server/forcessl.mw.js Normal file
View File

@@ -0,0 +1,7 @@
module.exports = (req, res, next) => {
if(process.env.NODE_ENV === 'local') return next();
if(req.header('x-forwarded-proto') !== 'https') {
return res.redirect(302, `https://${req.get('Host')}${req.url}`);
}
return next();
};