Fix https redirect

This commit is contained in:
Håvar Aambø Fosstveit
2018-10-26 20:30:54 +02:00
parent b5f50fd580
commit d7ce8253e2
+3 -5
View File
@@ -43,14 +43,12 @@ const dataporten = new Dataporten.Setup(config.oauth2);
app.all('*', (req, res, next) => app.all('*', (req, res, next) =>
{ {
if(req.headers['x-forwarded-proto'] == 'http') if(req.secure)
{
res.redirect('https://' + req.hostname + req.url);
}
else
{ {
return next(); return next();
} }
res.redirect('https://' + req.hostname + req.url);
}); });
app.use(dataporten.passport.initialize()); app.use(dataporten.passport.initialize());