Merge pull request #24 from dap-ps/add-https-redirect

add a redirect to https for production
This commit is contained in:
Andy Tudhope 2019-08-01 07:48:52 +02:00 committed by GitHub
commit 653f4758ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -8,6 +8,15 @@ class APIRouter {
/* for ElasticBeanstalk Load Balancer healthcheck */
app.use('/healthcheck', async (req, res) => res.send('OK'))
/* redirect if not on https on prod */
app.use(async (req, res, next) => {
if (req.get('x-forwarded-proto') == 'http') {
res.redirect('https://' + req.headers.host + req.url);
} else {
next()
}
});
}
}