Release v2.15.4
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile, web, pulse-signage-web) (push) Successful in 1m50s
Publish Docker Image / build-and-push-existing-registry (./build/Dockerfile.player, player, pulse-signage-player) (push) Successful in 34s

This commit is contained in:
lzstealth committed 2026-10-17 16:01:00 +01:00
1 parent 64aeb1b47e
commit 05c9341b08
25 files changed
+595 -31

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
function wantsHtmlErrorPage(req, res) {
const isXhr = String(req.get && req.get('X-Requested-With') || '').toLowerCase() === 'xmlhttprequest';
const requestPath = String(req.originalUrl || req.path || '');
const acceptsHtml = !req.accepts || req.accepts('html');
const contentType = String(res.get && res.get('Content-Type') || '').toLowerCase();
return !isXhr && requestPath.indexOf('/api/') !== 0 && acceptsHtml && (!contentType || contentType.indexOf('text/html') === 0);
}
function createErrorPage(pages, req, statusCode, message) {
const isServerError = statusCode >= 500;
return pages.renderErrorPage({
statusCode: statusCode,
message: isServerError ? '' : String(message || ''),
detail: isServerError ? 'The server could not complete the request.' : '',
backUrl: req.currentUser ? '/dashboard' : '/login',
backLabel: req.currentUser ? 'Back to dashboard' : 'Sign in'
}, req.currentUser);
}
module.exports = function registerErrorPageMiddleware(app, pages) {
app.use(function (req, res, next) {
const send = res.send;
const sendStatus = res.sendStatus;
res.send = function (body) {
const statusCode = Number(res.statusCode) || 200;
const isHtml = typeof body === 'string' && /^\s*</.test(body);
if (statusCode >= 400 && statusCode < 600 && !isHtml && wantsHtmlErrorPage(req, res)) {
return send.call(res, createErrorPage(pages, req, statusCode, body));
}
return send.apply(res, arguments);
};
res.sendStatus = function (statusCode) {
if (statusCode >= 400 && statusCode < 600 && wantsHtmlErrorPage(req, res)) {
res.statusCode = statusCode;
return res.send(createErrorPage(pages, req, statusCode));
}
return sendStatus.call(res, statusCode);
};
next();
});
};