Fix 500 error logging to show actual error instead of generic message

pino-http checks res.err before falling back to its generic
"failed with status code 500" error. Set res.err to the real error
in the error handler so logs include the actual message and stack trace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dotta
2026-03-05 13:28:26 -06:00
parent 185317c153
commit 690149d555
2 changed files with 8 additions and 7 deletions

View File

@@ -55,11 +55,7 @@ export const httpLogger = pinoHttp({
customErrorMessage(req, res) {
return `${req.method} ${req.url} ${res.statusCode}`;
},
customProps(_req, res) {
const serverError = (res as any).locals?.serverError;
if (serverError) {
return { serverError };
}
customProps() {
return {};
},
});