TanStackT
TanStack9mo ago
5 replies
static-pink

path error with static server function.

I have the following error when using a static server function. Any static function. Making it dynamic fixes the problem.


TypeError: The "path" argument must be of type string. Received undefined
    at validateString (node:internal/validators:162:11)
    at Module.join (node:path:1175:7)
    at Object.getItem (file:///Users/pupo/dev/chair-flight-new/node_modules/.pnpm/@tanstack+start-client-core@1.119.0/node_modules/@tanstack/start-client-core/dist/esm/createServerFn.js:185:31)
/...


Minimal code:

import { createFileRoute } from '@tanstack/react-router'
import { createServerFn } from '@tanstack/react-start';

const staticFn = createServerFn({ type: 'static' }).handler(() => "hello");

export const Route = createFileRoute('/_public/blog/potato')({
  component: RouteComponent,
  loader: () => staticFn(),
})

function RouteComponent() {
  const data = Route.useLoaderData();
  return <div>{data}</div>
}


the only fancy thing in my project is that it's integrated in a monorepo.

export default defineConfig({
  tsr: {
    appDirectory: 'apps/web-app/src',
  },
  routers: {
    public: {
      dir: "apps/web-app/public",
    }
  },
  server: {
    prerender: {
      routes: ["/blog"],
      crawlLinks: true,
    }
  },
  vite: {
    plugins: [
      tailwindcss(),
      tsConfigPaths({
        projects: ['apps/web-app/tsconfig.json'],
      }),
    ],
  },
})
Was this page helpful?