TanStackT
TanStack2mo ago
7 replies
dual-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 });
      },
    },
  },
});

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


If I change the status code to anything else then it shows proper response:
{"message":"User not found"}
image.png
Was this page helpful?