TanStackT
TanStack10mo ago
9 replies
progressive-amaranth

Import issue in routeTree.gen.ts when creating api routes

I have created an API route in src/routes/api/auth/$.ts :
import { createAPIFileRoute } from "@tanstack/react-start/api";
import { auth } from "@/lib/server/auth";

export const APIRoute = createAPIFileRoute("/api/auth/$")({
  GET: ({ request }) => {
    return auth.handler(request);
  },
  POST: ({ request }) => {
    return auth.handler(request);
  },
});

However, when the routeTree.gen.ts file gets regenerated it tries to import and use a named export called Route from the api route file which does not exist as the named export is called APIRoute.

import { Route as ApiAuthSplatImport } from './routes/api/auth.$'

...

const ApiAuthSplatRoute = ApiAuthSplatImport.update({
  id: '/api/auth/$',
  path: '/api/auth/$',
  getParentRoute: () => rootRoute,
} as any)

...


This causes an error as the import is incorrect. Am I missing some configuration or is this a known bug?
Was this page helpful?