Browse Source

Add setting to force redirect http to https

activitypub
Robbie Antenesse 3 years ago
parent
commit
4785ade1e2
  1. 9
      server.js
  2. 3
      settings.example.json

9
server.js

@ -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);

3
settings.example.json

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