Skip to content

Prerender fails when using custom base path - attempts to fetch / instead of configured base path #6023

Closed

Description

@busy-dog

Which project does this relate to?

Start

Describe the bug

When configuring a custom base path in Vite along with TanStack Router's basepath, the prerenderer still attempts to crawl from / instead of the configured base path, resulting in a "Failed to fetch /: Not Found" error during build.

Your Example Website or App

https://github.com/busy-dog/tanstack-start-demo

Steps to Reproduce the Bug or Issue

  1. Configure a custom base path in vite.config.ts:
const BASEPATH = '/gitlab/34e28e1e78c44601b0974c2097b85a27/caelum-doc-dist/';

export default defineConfig({
  base: BASEPATH,
  define: {
    BASEPATH: JSON.stringify(BASEPATH),
  },
  plugins: [
    tanstackStart({
      spa: {
        enabled: true,
        prerender: {
          outputPath: 'index.html',
          enabled: true,
          crawlLinks: false,
        },
      },
      pages: [
        { path: `/docs` },
        { path: `/api/search` },
      ],
    }),
  ],
});
  1. Configure router with basepath in router.tsx:
export function getRouter() {
  return createTanStackRouter({
    routeTree,
    basepath: BASEPATH,
    // ... other options
  });
}
  1. Run vite build

Build fails during prerender phase with:

[prerender] Crawling: /
error: Failed to fetch /: Not Found
  at <anonymous> (/node_modules/@tanstack/start-plugin-core/dist/esm/prerender.js:126:23)

Expected behavior

The prerenderer should respect the configured base path and attempt to fetch from /gitlab/34e28e1e78c44601b0974c2097b85a27/caelum-doc-dist/ instead of /.

Screenshots or Videos

No response

Platform

  • Router / Start Version: 1.139.14
  • OS: macOS
  • Browser: Chrome
  • Browser Version: 141
  • Bundler: vite
  • Bundler Version: 7.2.6

Additional context

No response

Activity

  1. nlynzaad commented on Dec 24, 2025

    @nlynzaad
    Contributor

    @busy-dog I cloned your repo and removing the trailing slash had it build correctly on my end. Please advise if this is the same for you.

  2. nlynzaad commented on Jan 6, 2026

    @nlynzaad
    Contributor

    @busy-dog this should now be supported with and without the trailing slash

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions