Can you redirect in server functions?
Is it possible to redirect in a server function? It's not working for me. I see a
uncaught (in promise)
error client-side.
Error:
Code:
5 Replies
extended-salmon•13mo ago
You need to wrap it in the
useServerFn
hook I believevicious-goldOP•13mo ago
Hmm yeah the redirect works now but sadly the cookies from
ctx.request.headers
aren't being setextended-salmon•13mo ago
Yeah that I'm unsure on
extended-salmon•13mo ago
Maybe you need to use get headers?
https://tanstack.com/router/latest/docs/framework/react/start/server-functions#accessing-headers
Server Functions | TanStack Router React Docs
What are Server Functions?
Server functions allow you to specify specific function to run only on the server. They are used to perform tasks that should never be directly exposed to the client.
vicious-goldOP•13mo ago
Thanks, didn't know about these functions. Using
setHeader
works!