Can't redirect in server functions with middleware
I am not sure if this is a known issue/limitation, but from what I can tell, throwing redirects in server functions that use middleware don't work. It works fine if I remove the middleware since I am using the
useServerFn()
helper hook on the client.
The problem seems to be that the isRedirect()
helper from @tanstack/router-core
expects the response to be a type of Response
with an options
prop.
When using middleware, the response is a plain object.6 Replies
itchy-amethyst•3mo ago
can you please create a github issue with a small reproducer?
ideally, a failing e2e test via a PR would be perfect 🙂
extended-salmonOP•3mo ago
Here's the bug report with a basic reproduction: https://github.com/TanStack/router/issues/4460
Got some other stuff on the plate that I need to look at so can't create a PR for this now.
GitHub
Can't redirect in server functions with middleware · Issue #4460 ...
Which project does this relate to? Start Describe the bug Throwing redirects in server functions that use middleware doesn't work. It works fine if I remove the middleware. I am using the useSe...
itchy-amethyst•3mo ago
thanks for the report!
deep-jade•3mo ago
Hey there, I’m running into the same issue, have you been able to figure out a temp workaround or a potential fix? If not, can I help?
itchy-amethyst•3mo ago
we are looking into this but have not yet identified the best way to solve this
extended-salmonOP•3mo ago
While the team is looking into it, I simply reverted to doing a manual client-side redirect.