Node.js based forum software built for the modern web
feat: update error handler to check for pseudo-standard no-* prefix and route to 404 handler instead
Julian Lamdb5b0f47e0e0
diff --git a/src/controllers/errors.js b/src/controllers/errors.jsindex 8071c54371..cd377f5d59 100644--- a/src/controllers/errors.js+++ b/src/controllers/errors.js@@ -48,6 +48,12 @@ exports.handleErrors = async function handleErrors(err, req, res, next) { // eslres.status(403).type('text/plain').send(err.message);},};++ const notFoundHandler = () => {+ const controllers = require('.');+ controllers['404'].handle404(req, res);+ };+const defaultHandler = async function () {if (res.headersSent) {return;@@ -87,6 +93,8 @@ exports.handleErrors = async function handleErrors(err, req, res, next) { // esltry {if (data.cases.hasOwnProperty(err.code)) {data.cases[err.code](err, req, res, defaultHandler);+ } else if (err.message.startsWith('[[error:no-') && err.message !== '[[error:no-privileges]]') {+ notFoundHandler();} else {await defaultHandler();}