router
router copied to clipboard
Can't redirect in server functions with middleware
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 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.
Your Example Website or App
https://codesandbox.io/p/devbox/thirsty-gould-yc3fks
Steps to Reproduce the Bug or Issue
- Click the button "With middleware (not working)" - notice no redirect
- Click the button "Without middleware (working)" - you get redirected to the /posts page
Expected behavior
I expect that redirects within server functions work regardless of whether I use middleware or not.
Screenshots or Videos
No response
Platform
I believe it is platform agnostic.
Additional context
No response