Issues with server routes
In Server Routes there are two examples that aren't working:
-
const { _splat } = params
-> _splat is undefined and i get typescript errors on that declaration.
- setResponseStatus
is not woring at allServer Routes | TanStack Start React Docs
Server routes are a powerful feature of TanStack Start that allow you to create server-side endpoints in your application and are useful for handling raw HTTP requests, form submissions, user authenti...
14 Replies
fair-rose•15h ago
setResponseStatus is not meant for server routes
docs needs updates there
you need to return a response
fascinating-indigoOP•15h ago
what about setResponseHeader(s) ?
i tried and it did not work
fair-rose•15h ago
same thing
we might be able to make it work, but why would you need it?
you are returning a raw response so you can set whatever you like
fascinating-indigoOP•15h ago
i just see the docs, so i try it 🙂
i need to know whether it works or not, what options there are etc etc
well, in the server routes docs it is advertised as helper function 😄 but sure, i can return a
Response
as usual 🙂fair-rose•15h ago
those need a lot of work. sorry about that
can you create a github issue about the docs please?
so either we make it work or fix the docs
fascinating-indigoOP•15h ago
of course 🙂 I will try to do it tomorrow
what about {_splat} pattern?
fascinating-indigoOP•15h ago
interesting status code does not work, however setREsponseHeader works!
you can see 200 (default) status, which was not changed, however new header was added

fair-rose•15h ago
hmm so some things make it through
please mention this in the github issue
fascinating-indigoOP•15h ago
what about _splat pattern?
fair-rose•15h ago
works for me
fair-rose•15h ago

fascinating-indigoOP•15h ago
github issue
https://github.com/TanStack/router/issues/5377
GitHub
setRespnoseStatus is not working (following docs on Server Routes) ...
Which project does this relate to? Start Describe the bug I was following the docs Server Routes There is written that we can use setResponseStatus helper funciton in Responding with a status code ...
fascinating-indigoOP•15h ago

fascinating-indigoOP•4h ago
i will com eback to it tomorrow, thanks for the help as usual!!
good night 🙂
Well, i did not deconstruct params properly...my bad, sorry
setResponseStatus and setResponseHeader work in server function (createServerFn+useServerFn)
however there is problem that json() helper method is not working (throwing typescript errors for incopatible return type)