redirect http => https before initializing reddit API (fixes #241)

This commit is contained in:
teddit 2021-09-19 20:48:51 +02:00
parent 9e515c4985
commit 8bb949b2b3

14
app.js
View File

@ -106,6 +106,13 @@ app.use(express.static(`${__dirname}/static`));
app.set('views', './views');
app.set('view engine', 'pug');
if (config.redirect_http_to_https) {
app.use((req, res, next) => {
if (req.secure) next();
else res.redirect(`https://${req.headers.host}${req.url}`);
});
}
const redditAPI = require('./inc/initRedditApi.js')(fetch);
/*
@ -121,13 +128,6 @@ app.use('/', allRoutes);
// The old routes
//require('./routes')(app, redis, fetch, redditAPI);
if (config.redirect_http_to_https) {
app.use((req, res, next) => {
if (req.secure) next();
else res.redirect(`https://${req.headers.host}${req.url}`);
});
}
const cacheControl = require('./cacheControl.js');
cacheControl.removeCacheFiles();