T
TanStack2w ago
extended-salmon

Server Routes don't show response data when status code is 404

import { createFileRoute } from "@tanstack/react-router";

export const Route = createFileRoute("/test")({
server: {
handlers: {
GET: () => {
return Response.json({ message: "User not found" }, { status: 404 });
},
},
},
});
import { createFileRoute } from "@tanstack/react-router";

export const Route = createFileRoute("/test")({
server: {
handlers: {
GET: () => {
return Response.json({ message: "User not found" }, { status: 404 });
},
},
},
});
This is an example of a simple code of server routes. I expected it to return data in JSON with the data as shown above but it only shows this in page:
Cannot GET /test
Cannot GET /test
If I change the status code to anything else then it shows proper response:
{"message":"User not found"}
{"message":"User not found"}
No description
7 Replies
extended-salmon
extended-salmonOP2w ago
Versions:
"@tanstack/react-query": "^5.90.9",
"@tanstack/react-query-devtools": "^5.84.2",
"@tanstack/react-router": "^1.136.6",
"@tanstack/react-router-devtools": "^1.136.6",
"@tanstack/react-router-ssr-query": "^1.136.6",
"@tanstack/react-start": "^1.136.6",
"@tanstack/react-query": "^5.90.9",
"@tanstack/react-query-devtools": "^5.84.2",
"@tanstack/react-router": "^1.136.6",
"@tanstack/react-router-devtools": "^1.136.6",
"@tanstack/react-router-ssr-query": "^1.136.6",
"@tanstack/react-start": "^1.136.6",
vicious-gold
vicious-gold2w ago
full reproducer project please
extended-salmon
extended-salmonOP2w ago
Sorry for being late but here is it: https://github.com/binamralamsal/tanstack-start-404-api-test Also, I found out that this bug only occurs in development. It works fine when running after build.
GitHub
GitHub - binamralamsal/tanstack-start-404-api-test
Contribute to binamralamsal/tanstack-start-404-api-test development by creating an account on GitHub.
vicious-gold
vicious-gold2w ago
probably this here
vicious-gold
vicious-gold2w ago
GitHub
notFoundComponent defined in __root not rendered when using nitro@3...
Which project does this relate to? Start Describe the bug The notFoundComponent defined in src/routes/__root.tsx is not rendered when using nitro@3.0.1-alpha.1, but it does work if we're not us...
vicious-gold
vicious-gold2w ago
please verify with latest nitro
extended-salmon
extended-salmonOP2w ago
I tested with nitro-nightly@3.0.1-20251118-175529-0316c6c6 and the issue has been fixed. Thank you so much for your help.

Did you find this page helpful?