Add: forceHttps (Closes #24)
This commit is contained in:
@@ -14,6 +14,10 @@ const config = {
|
|||||||
"sslPort": 8443,
|
"sslPort": 8443,
|
||||||
"sslKeyFile": false,
|
"sslKeyFile": false,
|
||||||
"sslCertFile": false,
|
"sslCertFile": false,
|
||||||
|
// Force redirect to https
|
||||||
|
// can be true or a specific url like https://example.com:8443
|
||||||
|
// keep empty to disable
|
||||||
|
"forceHttps": '',
|
||||||
// retention options in seconds:label
|
// retention options in seconds:label
|
||||||
"retentions": {
|
"retentions": {
|
||||||
"one-time": "one time download",
|
"one-time": "one time download",
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ if (config.accessLog) {
|
|||||||
app.use(morgan(config.accessLog));
|
app.use(morgan(config.accessLog));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(config.forceHttps) {
|
||||||
|
app.enable('trust proxy');
|
||||||
|
app.use(function(req, res, next) {
|
||||||
|
if (req.secure) return next();
|
||||||
|
const target = config.forceHttps === 'true' ? 'https://' + req.headers.host : config.forceHttps;
|
||||||
|
res.redirect(target + req.url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Static files
|
// Static files
|
||||||
app.use('/app', express.static(path.join(__dirname, '../public/app')));
|
app.use('/app', express.static(path.join(__dirname, '../public/app')));
|
||||||
app.use('/assets', express.static(path.join(__dirname, '../public/assets')));
|
app.use('/assets', express.static(path.join(__dirname, '../public/assets')));
|
||||||
|
|||||||
Reference in New Issue
Block a user