feat: ensure that all requests handled by NodeBB fall under the relative_path as configured

isekai-main
Julian Lam 3 years ago
parent 14e352470d
commit a3bdb70617

@ -59,6 +59,19 @@ middleware.ensureLoggedIn = (req, res, next) => {
setImmediate(next);
};
middleware.ensureRelativePath = (req, res, next) => {
const prefix = nconf.get('relative_path');
if (!prefix) {
return setImmediate(next);
}
if (!req.path.startsWith(prefix)) {
return controllers.helpers.redirect(res, req.path);
}
return next();
};
Object.assign(middleware, {
admin: require('./admin'),
...require('./header'),

@ -138,6 +138,8 @@ function setupExpressApp(app) {
app.use(compression());
}
app.use(middleware.ensureRelativePath);
app.get(`${relativePath}/ping`, pingController.ping);
app.get(`${relativePath}/sping`, pingController.ping);

Loading…
Cancel
Save