Goal
Secure the gateway API response format from leaking system implementation details.
Problem
In src/middleware/errorHandler.ts, if an unexpected 500 error is thrown (such as a database query timeout or table constraint error), the raw SQL error message err.message is returned to the client inside the JSON response even in production, exposing database structure details.
Task
- Update
src/middleware/errorHandler.ts to inspect the environment.
- If
env.NODE_ENV === 'production' and the response status is 500, mask the response message to a generic 'Internal Server Error' string.
- Ensure the detailed error log remains printed to
console.error for secure diagnostics.
Goal
Secure the gateway API response format from leaking system implementation details.
Problem
In
src/middleware/errorHandler.ts, if an unexpected 500 error is thrown (such as a database query timeout or table constraint error), the raw SQL error messageerr.messageis returned to the client inside the JSON response even in production, exposing database structure details.Task
src/middleware/errorHandler.tsto inspect the environment.env.NODE_ENV === 'production'and the response status is 500, mask the response message to a generic'Internal Server Error'string.console.errorfor secure diagnostics.