Skip to content

api route not found throws 404 #4873

Closed
Closed

Description

@mdrahiem

Which project does this relate to?

Start

Describe the bug

Initially I tried to build tanstack start app from scratch. I followed the documentation. When I created api route in routes/api/start.ts using createServerFileRoute then I called the endpoint in the component route. I see 404 being thrown.

So I tried with the example repo, examples/react/start-basic-react-query, when I run the app I see the same issue in the repo as well.

http://localhost:3000/api/users

Response:

<html>
    <head>
        <script class='$tsr'>
            (self.$R = self.$R || {})["tsr"] = [];
            self.$_TSR = {
                c: () => {
                    document.querySelectorAll(".\\$tsr").forEach(e => {
                        e.remove()
                    }
                    )
                }
            };
            ;$_TSR["router"] = ($R => $R[0] = {
                manifest: $R[1] = {
                    routes: $R[2] = {
                        __root__: $R[3] = {
                            preloads: void 0,
                            assets: $R[4] = [$R[5] = {
                                tag: "script",
                                attrs: $R[6] = {
                                    type: "module",
                                    suppressHydrationWarning: !0,
                                    async: !0
                                },
                                children: "import { injectIntoGlobalHook } from \"/@react-refresh\";\ninjectIntoGlobalHook(window);\nwindow.$RefreshReg$ = () => {};\nwindow.$RefreshSig$ = () => (type) => type;;;import('/~start/default-client-entry')"
                            }]
                        }
                    },
                    clientEntry: "/~start/default-client-entry"
                },
                matches: $R[7] = [$R[8] = {
                    i: "__root__",
                    u: 1754457363999,
                    s: "success",
                    ssr: !0
                }],
                lastMatchId: "__root__",
                dehydratedData: void 0
            })($R["tsr"]);
            if (typeof $_TSR !== 'undefined')
                $_TSR.c()
        </script>
        <meta charSet="utf-8"/>
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <title>TanStack Start Starter</title>
    </head>
    <body>
        <p>Not Found</p>
        <script type="module" async="">
            import {injectIntoGlobalHook} from "/@react-refresh";
            injectIntoGlobalHook(window);
            window.$RefreshReg$ = () => {}
            ;
            window.$RefreshSig$ = () => (type) => type;
            ;;import('/~start/default-client-entry')
        </script>
    </body>
</html>

Your Example Website or App

https://stackblitz.com/~/github.com/TanStack/router

Steps to Reproduce the Bug or Issue

  1. Clone the repo https://github.com/TanStack/router/tree/main/examples/react/start-basic-react-query
  2. Install and run the app
  3. Navigate to /users page
  4. You would see 404 in the Network tab
Image

Expected behavior

As a user, I should not be seeing 404 and the users route should work as expected

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.130.15
  • OS: macOS
  • Browser: Chrome
  • Browser Version: 138
  • Bundler: vite
  • Bundler Version: 6.3.5

Additional context

No response

Activity

  1. brenelz commented on Aug 8, 2025

    @brenelz
    Contributor

    From my quick test it seems that for the tanstack router example you linked it does show the users correctly

  2. schiller-manuel commented on Sep 23, 2025

    @schiller-manuel
    Collaborator

    server route handling changed in RC, please see the docs https://tanstack.com/start/latest/docs/framework/react/server-routes

    if there still is a problem, please open a new github issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions