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:
@@ -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 {};
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user