Render 404 pages for unmatched routes
Publish Docker Image / build-and-push (push) Successful in 26s

This commit is contained in:
2026-07-21 21:41:35 +01:00
parent cfca5bfe3b
commit 5e7df5e55c
+18
View File
@@ -225,6 +225,24 @@ async function start() {
});
app.use(function (req, res, next) {
const pathName = String(req.originalUrl || '');
const wantsHtml = !pathName.startsWith('/api/') && (!req.accepts || req.accepts('html'));
if (!wantsHtml) {
return next();
}
return res.status(404).send(pages.renderErrorPage({
statusCode: 404,
title: 'Not found',
errorTitle: 'Oops! Page not found.',
message: 'We could not find the page you were looking for.',
backUrl: req.currentUser ? '/admin' : '/login',
backLabel: req.currentUser ? 'Back to dashboard' : 'Sign in'
}, req.currentUser));
});
app.use(function (error, req, res, _next) {
console.error(error);
const statusCode = Number(error && (error.statusCode || error.status)) || 500;