Add setting to force redirect http to https

This commit is contained in:
Robbie Antenesse 2019-01-07 11:47:15 -07:00
parent 5f6d36d05b
commit 4785ade1e2
2 changed files with 11 additions and 1 deletions

View File

@ -55,6 +55,15 @@ function Server () {
if (fs.existsSync(path.resolve('./.well-known'))) {
this.server.use('/.well-known', express.static(path.resolve('./.well-known')));
}
if (this.https && settings.forceHTTPS) {
this.server.use(function (req, res, next) {
if (!req.secure) {
return res.redirect(['https://', req.get('Host'), req.baseUrl].join(''));
}
next();
});
}
this.server.get('/', (req, res) => {
const html = this.generateHomePage(req);

View File

@ -12,5 +12,6 @@
"hideVisitors": false,
"sslPrivateKey": null,
"sslCertificate": null,
"sslCertificateAuthority": null
"sslCertificateAuthority": null,
"forceHTTPS": false
}