Skip to content

Commit

Permalink
cover request.secure in HTTPS redirect exemption (nightscout#4483)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecubic authored and tanja3981 committed May 21, 2019
1 parent f7dbe11 commit 311bc55
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ function create(env, ctx) {
console.info('Security settings: INSECURE_USE_HTTP=',insecureUseHttp,', SECURE_HSTS_HEADER=',secureHstsHeader);
if (!insecureUseHttp) {
app.use((req, res, next) => {
if (req.header('x-forwarded-proto') !== 'https')
if (req.header('x-forwarded-proto') == 'https' || req.secure) {
next();
} else {
res.redirect(`https://${req.header('host')}${req.url}`);
else
next()
}
})
if (secureHstsHeader) { // Add HSTS (HTTP Strict Transport Security) header
const helmet = require('helmet');
Expand Down

0 comments on commit 311bc55

Please sign in to comment.