T
TanStack2mo ago
flat-fuchsia

Remove Error message from ServerFn

Hi! I want to make sure that server fns do not leak some information to the client through error messages. Is there a way to globally register a middleware that would handle this?
4 Replies
metropolitan-bronze
metropolitan-bronze2mo ago
hm not sure, can you please create a feature request on github for this? => https://github.com/TanStack/router/discussions/new?category=ideas
GitHub
Build software better, together
GitHub is where people build software. More than 150 million people use GitHub to discover, fork, and contribute to over 420 million projects.
From An unknown user
From An unknown user
From An unknown user
flat-fuchsia
flat-fuchsiaOP2mo ago
GitHub
Global ServerFn Middleware to Purge Error Message · TanStack route...
Is it possible to set-up a global ServerFn middleware to purge message from any server-side errors? I would like to do this as a paranoid precaution in case there is some sensitive information in s...
flat-fuchsia
flat-fuchsiaOP2mo ago
Actually, I guess it should be possible with a regular global middleware: https://tanstack.com/start/latest/docs/framework/react/middleware#global-middleware
Middleware | TanStack Start React Docs
What is Server Function Middleware? Middleware allows you to customize the behavior of server functions created with createServerFn with things like shared validation, context, and much more. Middlewa...
harsh-harlequin
harsh-harlequin2mo ago
Yeah, I catch and log errors in my global logging middleware. So you can definitely then choose to return whatever you want from that point if you don't want to rethrow the error. I'm still on 1.120.3 though until the official global middleware fix.

Did you find this page helpful?