feat: log 5xx errors to BSB observable via h3 onError

Both admin-http and api-http now log HTTP 500+ errors with status,
path, and error message to BSB observable (warn level). Makes
server-side errors visible in Coolify/container logs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mitchell R 2026-05-26 00:55:17 +02:00
parent e189d67faa
commit 0113e4e54a
No known key found for this signature in database
2 changed files with 26 additions and 2 deletions

View file

@ -195,7 +195,19 @@ export class Plugin extends BSBService<InstanceType<typeof Config>, typeof Event
otaImportApiKey: this.config.otaImportApiKey || undefined, otaImportApiKey: this.config.otaImportApiKey || undefined,
}; };
const app = new H3(); const app = new H3({
onError: (error, event) => {
const status = error.status ?? 500;
const path = event.req.url ?? "unknown";
if (status >= 500) {
obs.log.warn("HTTP {status} {path}: {err}", {
status,
path,
err: error.message ?? String(error),
});
}
},
});
registerMiddleware(app, deps); registerMiddleware(app, deps);
registerStaticRoutes(app); registerStaticRoutes(app);

View file

@ -164,7 +164,19 @@ export class Plugin extends BSBService<InstanceType<typeof Config>, typeof Event
}, },
); );
const app = new H3(); const app = new H3({
onError: (error, event) => {
const status = error.status ?? 500;
const path = event.req.url ?? "unknown";
if (status >= 500) {
obs.log.warn("HTTP {status} {path}: {err}", {
status,
path,
err: error.message ?? String(error),
});
}
},
});
app.get("/api/kiosk/_check", async (event) => { app.get("/api/kiosk/_check", async (event) => {
const token = extractBearerToken(event); const token = extractBearerToken(event);