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...
16 Replies
national-gold•2mo ago
setResponseStatus is not meant for server routes
docs needs updates there
you need to return a response
absent-sapphireOP•2mo ago
what about setResponseHeader(s) ?
i tried and it did not work
national-gold•2mo 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
absent-sapphireOP•2mo 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 🙂national-gold•2mo 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
absent-sapphireOP•2mo ago
of course 🙂 I will try to do it tomorrow
what about {_splat} pattern?
absent-sapphireOP•2mo 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

national-gold•2mo ago
hmm so some things make it through
please mention this in the github issue
absent-sapphireOP•2mo ago
what about _splat pattern?
national-gold•2mo ago
works for me
national-gold•2mo ago

absent-sapphireOP•2mo 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 ...
absent-sapphireOP•2mo ago

absent-sapphireOP•2mo 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)
national-gold•2mo ago
is this mentioned in the docs for server functions?
in server functions you just return the thing you want to return directly
absent-sapphireOP•2mo ago
yea, and no, this is not mentioned in the docs, that was my idea and i was wondering if that's on purpose or note