fix: vite preview base path support #6304
main fromrefs/pull/6304/head·merged by nlynzaad(GitHub profile, opens in a new tab) Fix #6023
It seems like the Vite preview server currently strip out the base path from the request URL. This prepends it back to restore the actual URL that hits the preview server.
We are also enforcing trailing slash to the prerendering requests so we won't get a 404 response when base path has a trailing slash.
One thing I am not sure though is the log output. The prerendered pages is not actually saved in a test folder but the logs makes it looks like that when I verify it with the start-basic-static example.
| Without base path | With base path |
|---|---|
| Prerendered 36 pages: | Prerendered 37 pages: |
| - / | - / |
| - /test/ | |
| - /users | - /test/route-a |
| - /posts | - /test/posts |
| - /route-a | - /test/users |
| - /users/1 | - /test/route-b |
| - /users/4 | - /test/posts/1 |
| - /users/5 | - /test/posts/5 |
| - /users/2 | - /test/posts/4 |
| - /users/3 | - /test/posts/2 |
| - /users/7 | - /test/posts/3 |
| - /users/6 | - /test/posts/6 |
| - /users/9 | - /test/posts/7 |
| - /users/10 | - /test/posts/8 |
| - /users/8 | - /test/posts/9 |
| - /posts/1 | - /test/posts/10 |
| - /posts/2 | - /test/users/1 |
| - /posts/3 | - /test/users/2 |
| - /posts/4 | - /test/users/3 |
| - /posts/5 | - /test/users/4 |
| - /posts/6 | - /test/users/5 |
| - /posts/7 | - /test/users/6 |
| - /posts/8 | - /test/users/7 |
| - /posts/9 | - /test/users/8 |
| - /posts/10 | - /test/users/9 |
| - /route-b | - /test/users/10 |
| - /posts/1/deep | - /test/posts/1/deep |
| - /posts/2/deep | - /test/posts/5/deep |
| - /posts/3/deep | - /test/posts/4/deep |
| - /posts/5/deep | - /test/posts/2/deep |
| - /posts/4/deep | - /test/posts/3/deep |
| - /posts/6/deep | - /test/posts/6/deep |
| - /posts/7/deep | - /test/posts/7/deep |
| - /posts/8/deep | - /test/posts/8/deep |
| - /posts/9/deep | - /test/posts/9/deep |
| - /posts/10/deep | - /test/posts/10/deep |
| - /deferred | - /test/deferred |
Summary by CodeRabbit#
Release Notes#
- New Features
- Added support for deploying applications to a subpath (e.g.,
/test/), enabling better flexibility for hosting configurations and routing resolution across the application.
- Added support for deploying applications to a subpath (e.g.,
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-plugin-core
View your CI Pipeline Execution ↗ for commit b6f260ee40c5f4b503994b0c7d61eadda669739a
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 17m 4s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 20s View ↗
☁️ Nx Cloud last updated this comment at
2026-01-06 20:12:34UTCMore templates
- tanstack-router-vue-example-basic-jsx
- tanstack-router-vue-example-basic-file-based-jsx
- tanstack-router-vue-example-basic-file-based-sfc
- tanstack-router-solid-example-authenticated-routes
- tanstack-router-solid-example-authenticated-routes-firebase
- tanstack-router-solid-example-basic
- tanstack-router-solid-example-basic-default-search-params
- tanstack-router-solid-example-basic-devtools-panel
- tanstack-router-solid-example-basic-file-based
- tanstack-router-solid-example-basic-non-nested-devtools
- tanstack-router-solid-example-basic-solid-query
- tanstack-router-solid-example-basic-solid-query-file-based
- tanstack-router-solid-example-basic-ssr-file-based
- tanstack-router-solid-example-basic-ssr-streaming-file-based
- tanstack-router-solid-example-basic-virtual-file-based
- tanstack-router-solid-example-basic-virtual-inside-file-based
- tanstack-router-solid-example-deferred-data
- tanstack-router-solid-i18n-paraglide
- tanstack-router-solid-example-kitchen-sink
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-kitchen-sink-solid-query
- tanstack-router-solid-example-kitchen-sink-solid-query-file-based
- tanstack-router-solid-example-large-file-based
- tanstack-router-solid-example-location-masking
- tanstack-router-solid-example-navigation-blocking
- tanstack-router-solid-example-quickstart
- tanstack-router-solid-example-quickstart-esbuild-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-router-solid-example-quickstart-rspack-file-based
- tanstack-router-solid-example-quickstart-webpack-file-based
- @tanstack/router-solid-mono-simple
- router-solid-mono-simple-lazy
- router-solid-monorepo-solid-query
- tanstack-router-solid-example-scroll-restoration
- tanstack-solid-router-search-validator-adapters
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-auth
- tanstack-solid-start-example-basic-authjs
- tanstack-solid-start-example-basic-cloudflare
- tanstack-solid-start-example-basic-netlify
- tanstack-solid-start-example-basic-nitro
- tanstack-start-example-basic-solid-query
- tanstack-solid-start-example-basic-static
- tanstack-solid-start-bun-hosting
- tanstack-solid-start-example-convex-better-auth
- tanstack-solid-start-example-counter
- tanstack-solid-start-i18n-paraglide
- tanstack-solid-start-example-large
- tanstack-solid-start-streaming-data-from-server-functions
- tanstack-solid-start-example-supabase-basic
- tanstack-solid-start-tailwind-v4
- tanstack-router-solid-example-view-transitions
- tanstack-router-solid-example-with-framer-motion
- tanstack-router-solid-example-with-trpc
- tanstack-router-react-example-authenticated-routes
- tanstack-router-react-example-authenticated-routes-firebase
- tanstack-router-react-example-basic
- tanstack-router-react-example-basic-default-search-params
- tanstack-router-react-example-basic-devtools-panel
- tanstack-router-react-example-basic-file-based
- tanstack-router-react-example-basic-non-nested-devtools
- tanstack-router-react-example-react-query
- tanstack-router-react-example-basic-react-query-file-based
- tanstack-router-react-example-basic-ssr-file-based
- tanstack-router-react-example-basic-ssr-streaming-file-based
- tanstack-router-react-example-basic-virtual-file-based
- tanstack-router-react-example-basic-virtual-inside-file-based
- tanstack-router-react-example-deferred-data
- tanstack-router-i18n-paraglide
- tanstack-router-react-example-kitchen-sink
- tanstack-router-react-example-kitchen-sink-file-based
- tanstack-router-react-example-kitchen-sink-react-query
- tanstack-router-react-example-kitchen-sink-react-query-file-based
- tanstack-router-react-example-large-file-based
- tanstack-router-react-example-location-masking
- tanstack-router-react-example-navigation-blocking
- tanstack-router-react-example-quickstart
- tanstack-router-react-example-quickstart-esbuild-file-based
- tanstack-router-react-example-quickstart-file-based
- tanstack-router-react-example-quickstart-rspack-file-based
- tanstack-router-react-example-quickstart-webpack-file-based
- router-monorepo-react-query
- router-mono-simple
- router-mono-simple-lazy
- tanstack-router-react-example-scroll-restoration
- tanstack-search-validator-adapters
- tanstack-start-example-bare
- tanstack-start-example-basic
- tanstack-start-example-basic-auth
- tanstack-router-react-example-basic-authjs
- tanstack-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-rsc
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-clerk-basic
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- tanstack-start-streaming-data-from-server-functions
- tanstack-start-example-supabase-basic
- tanstack-start-tailwind-v4
- tanstack-start-example-trellaux
- tanstack-start-example-workos
- tanstack-router-react-example-view-transitions
- tanstack-router-react-example-with-framer-motion
- tanstack-router-react-example-with-trpc
- tanstack-router-react-example-with-trpc-react-query
@tanstack/arktype-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/arktype-adapter@6304@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@6304@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@6304@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@6304@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@6304@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@6304@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@6304@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@6304@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@6304@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@6304@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@6304@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@6304@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@6304@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@6304@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@6304@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@6304@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@6304@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@6304@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@6304@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@6304@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@6304@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-ssr-query@6304@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@6304@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@6304@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@6304@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@6304@tanstack/start-fn-stubs
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-fn-stubs@6304@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@6304@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@6304@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@6304@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@6304@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@6304@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@6304@tanstack/vue-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router@6304@tanstack/vue-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-devtools@6304@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-router-ssr-query@6304@tanstack/vue-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start@6304@tanstack/vue-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-client@6304@tanstack/vue-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/vue-start-server@6304@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@6304commit:
b6f260ethis looks good. I've resolved the prettier error on the import orders and merged main that includes updates for the failures on react-start-basic raw stream tests (these were flaky and was not due to any changes in this PR)
nlynzaad(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
📝 Walkthrough
Walkthrough#
This change adds custom base path support to the TanStack Start prerender and preview server workflows. Configuration examples are updated with a
/test/base path, the prerender fetch URL is wrapped with a trailing slash to ensure proper resolution, and the preview server middleware prepends the configured base path to incoming request URLs.Changes#
examples/react/start-basic-static/src/router.tsx,examples/react/start-basic-static/vite.config.tsbasepath: '/test/'to router creation andbase: '/test/'to Vite config to demonstrate custom base path setup in test example.packages/start-plugin-core/src/prerender.tswithTrailingSlashfrom 'ufo' and wrapped the fetch URL construction to ensure trailing slash is applied after base path resolution.packages/start-plugin-core/src/preview-server-plugin/plugin.tsjoinURLfrom 'ufo' and prepended the configured server base path to incoming request URLs before constructing NodeRequest and invoking the server build.Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs#
Suggested reviewers#
Poem#
Pre-merge checks and finishing touches#
❌ Failed checks (1 warning)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (4 passed)
✨ Finishing touches
📜 Recent review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 2ea1abb9efdd38f29be19fb9a297c2ef37bb1aaf and b6f260ee40c5f4b503994b0c7d61eadda669739a.
📒 Files selected for processing (4)
examples/react/start-basic-static/src/router.tsxexamples/react/start-basic-static/vite.config.tspackages/start-plugin-core/src/prerender.tspackages/start-plugin-core/src/preview-server-plugin/plugin.ts🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Files:
examples/react/start-basic-static/vite.config.tspackages/start-plugin-core/src/prerender.tspackages/start-plugin-core/src/preview-server-plugin/plugin.tsexamples/react/start-basic-static/src/router.tsx**/*.{js,ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Files:
examples/react/start-basic-static/vite.config.tspackages/start-plugin-core/src/prerender.tspackages/start-plugin-core/src/preview-server-plugin/plugin.tsexamples/react/start-basic-static/src/router.tsx🧠 Learnings (7)
📓 Common learnings
📚 Learning: 2025-12-21T12:52:35.231Z
Applied to files:
packages/start-plugin-core/src/prerender.tsexamples/react/start-basic-static/src/router.tsx📚 Learning: 2025-10-01T18:30:26.591Z
Applied to files:
packages/start-plugin-core/src/prerender.tsexamples/react/start-basic-static/src/router.tsx📚 Learning: 2025-12-24T22:47:44.320Z
Applied to files:
packages/start-plugin-core/src/prerender.ts📚 Learning: 2025-12-17T02:17:55.086Z
Applied to files:
packages/start-plugin-core/src/prerender.tsexamples/react/start-basic-static/src/router.tsx📚 Learning: 2025-12-06T15:03:07.223Z
Applied to files:
examples/react/start-basic-static/src/router.tsx📚 Learning: 2025-10-08T08:11:47.088Z
Applied to files:
examples/react/start-basic-static/src/router.tsx⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share