From f1f21df46da806a68d6f64504abb61de418b0230 Mon Sep 17 00:00:00 2001 From: benweet Date: Mon, 7 Oct 2013 02:11:56 +0100 Subject: [PATCH] Force https on stackedit.io --- server.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/server.js b/server.js index 9957769e..c89d8559 100644 --- a/server.js +++ b/server.js @@ -1,5 +1,14 @@ var express = require('express'); var app = express(); +app.all('*', function(req, res, next) { + console.log(req.headers); + if (req.headers.host == 'stackedit.io' && req.headers['x-forwarded-proto'] != 'https') { + res.redirect('https://stackedit.io' + req.url); + } + else { + next(); + } +}); app.use(express.compress()); app.use(express.static(__dirname + '/public')); app.listen(process.env.PORT || 3000); \ No newline at end of file