A @tanstack.com start design question ( @tannerlinsley.com @tkdodo.eu ) Why do you have to THROW a redirect instead of (early) returning it? tanstack.com/start/latest... Throw is commonly supposed to handle an erroneous situation. Redirect doesn't seem like one. TIA for response!
Post
tanstack.comServer Functions | TanStack Start React DocsWhat are Server Functions? Server functions allow you to specify logic that can be invoked almost anywhere (even the client), but run only on the server. In fact, they are not so different from an API...
I understand I "can" do lots of things within a specific API design. But redirect seems a really normal result. Throwing is commonly used for abnormal interruption. Not to mention that SE in general is slightly moving away from exceptions, mostly, due to overhead due to building stack traces.
0 reposts1 like
I think I was using Remix a few years ago and I returned a redirect and some data. Now in the code I had to check if the response was a redirect, but the way redirects work your code in the frontend for that redirect won't run because the redirect has interrupted it and moves the flow to another url