warflash
warflash5mo ago

How to prevent leaking error messages to client?

Hey everyone! I noticed that TRPC seems to log quite extensive error codes in the response body of failed requests, even in production builds. I really don't want my users to be able to see e.g. Error: connect ECONNREFUSED 10.1.0.6:5432\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16)\n Thanks!
No description
2 Replies
infodusha
infodusha5mo ago
you can write a middleware that with catch your errors and rethrow them with less info
SiNONiMiTY
SiNONiMiTY4mo ago
this error stack is not visible when you set NODE_ENV="production"