agent: Set missing CONTACT_EMAIL_TO environment variable

This commit is contained in:
platform-mcp
2026-06-17 20:12:04 +05:30
parent 2291336300
commit 8e60268caf
+20 -1
View File
@@ -106,7 +106,26 @@ export const onRequest = defineMiddleware(async (context, next) => {
if (status >= 500) { if (status >= 500) {
logger.error('middleware', `SSR error ${status}`, { method, path, status, durationMs }); logger.error('middleware', `SSR error ${status}`, { method, path, status, durationMs });
} else if (status === 404) { } else if (status === 404) {
logger.warn('middleware', `Not found`, { method, path, status, durationMs }); // 404s are dominated by bots/scanners probing malformed or garbage paths
// (e.g. "/)"), which would otherwise flood warn-level logs and trip alerts.
// Treat a 404 as a warning only when it likely originated from our own site
// (same-origin referer) — that indicates a real broken internal link worth
// fixing. Everything else (no referer / external referer) is logged at info.
const referer = context.request.headers.get('referer');
let internalNavigation = false;
if (referer) {
try {
internalNavigation = new URL(referer).hostname === context.url.hostname;
} catch {
// Malformed referer header → treat as external/untrusted
}
}
const notFoundMeta = { method, path, status, durationMs, referer: referer ?? undefined };
if (internalNavigation) {
logger.warn('middleware', `Not found (broken internal link)`, notFoundMeta);
} else {
logger.info('middleware', `Not found`, notFoundMeta);
}
} else if (status >= 400) { } else if (status >= 400) {
logger.warn('middleware', `Client error ${status}`, { method, path, status, durationMs }); logger.warn('middleware', `Client error ${status}`, { method, path, status, durationMs });
} else { } else {