From f9ea74d97cd465bd12ece09e3af92c5b21acbbf8 Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Mon, 5 Jan 2026 08:35:05 +0100 Subject: [PATCH 1/4] fix: vite preview base path support --- .../start-plugin-core/src/preview-server-plugin/plugin.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/start-plugin-core/src/preview-server-plugin/plugin.ts b/packages/start-plugin-core/src/preview-server-plugin/plugin.ts index 5322ef94438..3257a8323b7 100644 --- a/packages/start-plugin-core/src/preview-server-plugin/plugin.ts +++ b/packages/start-plugin-core/src/preview-server-plugin/plugin.ts @@ -1,6 +1,7 @@ import { pathToFileURL } from 'node:url' import { basename, extname, join } from 'pathe' import { NodeRequest, sendNodeResponse } from 'srvx/node' +import { joinURL } from 'ufo' import { VITE_ENVIRONMENT_NAMES } from '../constants' import { getServerOutputDirectory } from '../output-directory' import type { Plugin } from 'vite' @@ -43,6 +44,9 @@ export function previewServerPlugin(): Plugin { serverBuild = imported.default } + // Prepend base path to request URL to match routing setup + req.url = joinURL(server.config.base, req.url ?? '/') + const webReq = new NodeRequest({ req, res }) const webRes: Response = await serverBuild.fetch(webReq) From 1ca9a466d5692d529720790e803212e2b6dd2b20 Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Mon, 5 Jan 2026 09:15:31 +0100 Subject: [PATCH 2/4] fix: base name with trailing slash support --- packages/start-plugin-core/src/prerender.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/start-plugin-core/src/prerender.ts b/packages/start-plugin-core/src/prerender.ts index ea6368109e5..daeacc2f6f5 100644 --- a/packages/start-plugin-core/src/prerender.ts +++ b/packages/start-plugin-core/src/prerender.ts @@ -1,7 +1,7 @@ import { promises as fsp } from 'node:fs' import os from 'node:os' import path from 'pathe' -import { joinURL, withBase, withoutBase } from 'ufo' +import { joinURL, withBase, withoutBase, withTrailingSlash } from 'ufo' import { VITE_ENVIRONMENT_NAMES } from './constants' import { createLogger } from './utils' import { Queue } from './queue' @@ -164,7 +164,7 @@ export async function prerender({ // Fetch the route const res = await localFetch( - withBase(page.path, routerBasePath), + withTrailingSlash(withBase(page.path, routerBasePath)), { headers: { ...(prerenderOptions.headers ?? {}), From a0b331dc67db0a90a17e8598ffe0db3c920301e3 Mon Sep 17 00:00:00 2001 From: Edmund Hung Date: Mon, 5 Jan 2026 09:16:23 +0100 Subject: [PATCH 3/4] update example for demo purpose --- examples/react/start-basic-static/src/router.tsx | 1 + examples/react/start-basic-static/vite.config.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/react/start-basic-static/src/router.tsx b/examples/react/start-basic-static/src/router.tsx index 1a1d8822d20..5b15fa10597 100644 --- a/examples/react/start-basic-static/src/router.tsx +++ b/examples/react/start-basic-static/src/router.tsx @@ -6,6 +6,7 @@ import { NotFound } from './components/NotFound' export function getRouter() { const router = createRouter({ routeTree, + basepath: '/test/', defaultPreload: 'intent', defaultErrorComponent: DefaultCatchBoundary, defaultNotFoundComponent: () => , diff --git a/examples/react/start-basic-static/vite.config.ts b/examples/react/start-basic-static/vite.config.ts index b7eb5b4439f..0de9a0db198 100644 --- a/examples/react/start-basic-static/vite.config.ts +++ b/examples/react/start-basic-static/vite.config.ts @@ -5,6 +5,7 @@ import viteReact from '@vitejs/plugin-react' import tailwindcss from '@tailwindcss/vite' export default defineConfig({ + base: '/test/', server: { port: 3000, }, From b77e89446c907f3e767ba0d8b336512fce55bc5c Mon Sep 17 00:00:00 2001 From: Nico Lynzaad Date: Mon, 5 Jan 2026 21:48:48 +0200 Subject: [PATCH 4/4] prettier: resolve import order --- packages/start-plugin-core/src/prerender.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/start-plugin-core/src/prerender.ts b/packages/start-plugin-core/src/prerender.ts index daeacc2f6f5..38b9223e188 100644 --- a/packages/start-plugin-core/src/prerender.ts +++ b/packages/start-plugin-core/src/prerender.ts @@ -1,7 +1,7 @@ import { promises as fsp } from 'node:fs' import os from 'node:os' import path from 'pathe' -import { joinURL, withBase, withoutBase, withTrailingSlash } from 'ufo' +import { joinURL, withBase, withTrailingSlash, withoutBase } from 'ufo' import { VITE_ENVIRONMENT_NAMES } from './constants' import { createLogger } from './utils' import { Queue } from './queue'