T
TanStack•15h ago
fascinating-indigo

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 all
Server 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
fair-rose•15h ago
setResponseStatus is not meant for server routes docs needs updates there you need to return a response
fascinating-indigo
fascinating-indigoOP•15h ago
what about setResponseHeader(s) ? i tried and it did not work
fair-rose
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-indigo
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
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-indigo
fascinating-indigoOP•15h ago
of course 🙂 I will try to do it tomorrow what about {_splat} pattern?
fascinating-indigo
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
No description
fair-rose
fair-rose•15h ago
hmm so some things make it through please mention this in the github issue
fascinating-indigo
fascinating-indigoOP•15h ago
what about _splat pattern?
fair-rose
fair-rose•15h ago
works for me
fair-rose
fair-rose•15h ago
No description
fascinating-indigo
fascinating-indigoOP•15h ago
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-indigo
fascinating-indigoOP•15h ago
No description
fascinating-indigo
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)

Did you find this page helpful?