fix: basepath #5345
main fromrefs/pull/5345/head·merged by schiller-manuel(GitHub profile, opens in a new tab) Summary by CodeRabbit#
New Features
- Router supports a runtime basepath option applied during hydration; manifests and prerendering use configured basepaths. Vite base is respected for public paths.
Refactor
- Public API surface simplified (rewriteBasepath removed); manifest retrieval call simplified to no-arg form. Client/server RPC and URL handling unified to rely on environment-driven bases.
Bug Fixes
- More consistent asset and navigation URL resolution under custom base paths.
Chores
- Environment vars updated: TSS_APP_BASE removed; TSS_ROUTER_BASEPATH and TSS_SERVER_FN_BASE required.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: react-router
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: router-core
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: solid-router
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-plugin-core
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-server-core
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-client-core
View your CI Pipeline Execution ↗ for commit 7b1b6847e20fd2bd88385cbbf592c5ce24571aba
Command Status Duration Result nx affected --targets=test:eslint,test:unit,tes...✅ Succeeded 3m 43s View ↗ nx run-many --target=build --exclude=examples/*...✅ Succeeded 24s View ↗
☁️ Nx Cloud last updated this comment at
2025-10-03 12:56:53UTCActionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/start-plugin-core/src/prerender.ts (1)
141-185: Restore leading slash before callingwithBase.startConfig.router.basepathis normalized elsewhere to strip leading/trailing slashes, so values like'foo'reach here. Passing that directly towithBaseproduces'foo/...', which makeslocalFetchbuild bad URLs (http://localhostfoo/...) and causes prerender fetches/writes to miss the intended base path.Add back the leading slash before composing URLs, e.g.:
- const routerBasePath = startConfig.router.basepath || '/' + const routerBasePath = joinURL('/', startConfig.router.basepath ?? '')🧹 Nitpick comments (1)
packages/start-server-core/src/createStartHandler.ts (1)
174-174: Direct env var access without fallback.Unlike line 57 which provides a fallback for
TSS_ROUTER_BASEPATH, this line directly accessesprocess.env.TSS_SERVER_FN_BASE. If the env var is not set,href.startsWith(undefined)will be called, which convertsundefinedto"undefined"and performs a string comparison that will always be false.While the current behavior is safe (won't crash), it's less clear than an explicit check. Consider adding a constant with validation:
const SERVER_FN_BASE = process.env.TSS_SERVER_FN_BASE if (!SERVER_FN_BASE) { throw new Error('TSS_SERVER_FN_BASE environment variable is required') } // Later at line 174: if (href.startsWith(SERVER_FN_BASE)) {📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between ac35dd23822a0eb9f4f8835110d94b5f63c095b8 and 6f50f8e93bfb2b4dbb32452e206d8d952cc7e21f.
📒 Files selected for processing (19)
examples/react/start-basic/vite.config.ts(1 hunks)packages/react-router/src/index.tsx(1 hunks)packages/react-router/tests/router.test.tsx(11 hunks)packages/router-core/src/index.ts(0 hunks)packages/router-core/src/router.ts(3 hunks)packages/solid-router/src/index.tsx(1 hunks)packages/start-client-core/src/client-rpc/createClientRpc.ts(1 hunks)packages/start-client-core/src/client/hydrateStart.ts(1 hunks)packages/start-plugin-core/src/global.d.ts(0 hunks)packages/start-plugin-core/src/plugin.ts(6 hunks)packages/start-plugin-core/src/prerender.ts(3 hunks)packages/start-plugin-core/src/schema.ts(1 hunks)packages/start-plugin-core/src/start-manifest-plugin/plugin.ts(6 hunks)packages/start-server-core/src/createServerRpc.ts(1 hunks)packages/start-server-core/src/createStartHandler.ts(4 hunks)packages/start-server-core/src/global.d.ts(1 hunks)packages/start-server-core/src/request-response.ts(1 hunks)packages/start-server-core/src/router-manifest.ts(1 hunks)packages/start-server-core/src/server-functions-handler.ts(2 hunks)
💤 Files with no reviewable changes (2)
- packages/router-core/src/index.ts
- packages/start-plugin-core/src/global.d.ts
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/start-server-core/src/router-manifest.tsexamples/react/start-basic/vite.config.tspackages/react-router/src/index.tsxpackages/start-server-core/src/global.d.tspackages/start-server-core/src/createServerRpc.tspackages/start-client-core/src/client/hydrateStart.tspackages/start-plugin-core/src/plugin.tspackages/start-server-core/src/createStartHandler.tspackages/start-plugin-core/src/start-manifest-plugin/plugin.tspackages/start-server-core/src/request-response.tspackages/start-plugin-core/src/prerender.tspackages/start-plugin-core/src/schema.tspackages/react-router/tests/router.test.tsxpackages/router-core/src/router.tspackages/solid-router/src/index.tsxpackages/start-server-core/src/server-functions-handler.tspackages/start-client-core/src/client-rpc/createClientRpc.ts
packages/{*-start,start-*}/**
📄 CodeRabbit inference engine (AGENTS.md)
Name and place Start framework packages under packages/-start/ or packages/start-/
Files:
packages/start-server-core/src/router-manifest.tspackages/start-server-core/src/global.d.tspackages/start-server-core/src/createServerRpc.tspackages/start-client-core/src/client/hydrateStart.tspackages/start-plugin-core/src/plugin.tspackages/start-server-core/src/createStartHandler.tspackages/start-plugin-core/src/start-manifest-plugin/plugin.tspackages/start-server-core/src/request-response.tspackages/start-plugin-core/src/prerender.tspackages/start-plugin-core/src/schema.tspackages/start-server-core/src/server-functions-handler.tspackages/start-client-core/src/client-rpc/createClientRpc.ts
examples/{react,solid}/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep example applications under examples/react/ and examples/solid/
Files:
examples/react/start-basic/vite.config.ts
packages/{react-router,solid-router}/**
📄 CodeRabbit inference engine (AGENTS.md)
Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
Files:
packages/react-router/src/index.tsxpackages/react-router/tests/router.test.tsxpackages/solid-router/src/index.tsx
packages/router-core/**
📄 CodeRabbit inference engine (AGENTS.md)
Keep framework-agnostic core router logic in packages/router-core/
Files:
packages/router-core/src/router.ts
🧬 Code graph analysis (4)
packages/start-plugin-core/src/plugin.ts (1)
packages/router-core/src/index.ts (2)
trimPathRight(98-98)joinPaths(95-95)
packages/start-server-core/src/createStartHandler.ts (1)
packages/start-server-core/src/router-manifest.ts (1)
getStartManifest(11-59)
packages/start-plugin-core/src/start-manifest-plugin/plugin.ts (1)
packages/start-plugin-core/src/plugin.ts (1)
GetConfigFn(47-50)
packages/router-core/src/router.ts (1)
packages/router-core/src/rewrite.ts (1)
rewriteBasepath(21-55)
🪛 ast-grep (0.39.5)
packages/start-server-core/src/server-functions-handler.ts
[warning] 27-27: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns. Context: new RegExp(
${process.env.TSS_SERVER_FN_BASE}([^/?#]+)) Note: [CWE-1333] Inefficient Regular Expression Complexity [REFERENCES]- https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS
- https://cwe.mitre.org/data/definitions/1333.html
(regexp-from-variable)
⏰ 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). (2)
- GitHub Check: Test
- GitHub Check: Preview
🔇 Additional comments (8)
packages/start-server-core/src/request-response.ts (1)
48-59: Remove commented-outh3_toResponsecall TheRequestHandleralready returns aResponse(orPromise<Response>), and there are no remainingtoResponsereferences—delete the// h3_toResponse(response, h3Event)on line 57.packages/start-plugin-core/src/plugin.ts (1)
103-106: Fix invalidString.replacecall.String.prototype.replaceaccepts only two arguments, but this call passes three, triggering a type error and breaking the build. Drop the superfluous empty string:- startConfig.router.basepath = startConfig.router.basepath.replace( - /^\/|\/$/g, - '', - '', - ) + startConfig.router.basepath = startConfig.router.basepath.replace( + /^\/|\/$/g, + '', + )Likely an incorrect or invalid review comment.
packages/start-server-core/src/server-functions-handler.ts (2)
27-29: ReDoS warning is a false positive for this pattern.The static analysis tool flags regexp construction from variable input as a potential ReDoS risk. However, the pattern
${process.env.TSS_SERVER_FN_BASE}([^/?#]+)is safe because:- The interpolated
TSS_SERVER_FN_BASEis a build-time/config-time constant, not user input - The capture group
[^/?#]+uses a negated character class that matches efficiently without backtracking - The pattern is bounded by URL structure (no nested quantifiers or alternations)
Based on static analysis hints.
13-13: Lazy initialization pattern is efficient.The module-level regex with lazy initialization on first call is a good performance optimization, avoiding regex compilation on module load.
Also applies to: 27-29
packages/start-server-core/src/createStartHandler.ts (2)
57-57: Fallback to '/' is good defensive programming.Despite
global.d.tsdeclaringTSS_ROUTER_BASEPATHas required, providing a fallback to'/'is prudent defensive programming that prevents runtime errors. However, this creates an inconsistency between the type declaration and actual usage.Consider updating
global.d.tsto makeTSS_ROUTER_BASEPATHoptional to match this defensive usage, or document that the fallback is intentional for backwards compatibility.
211-211: LGTM: Aligns with updated getStartManifest signature.The call to
getStartManifest()without arguments correctly matches the updated signature that removed thebasePathparameter.packages/start-server-core/src/router-manifest.ts (1)
11-11: Breaking change: remove basePath parameter All internal calls now usegetStartManifest()without arguments—verified. Update any external callers accordingly.packages/start-client-core/src/client-rpc/createClientRpc.ts (1)
5-5: TSS_SERVER_FN_BASE is already normalized with a single trailing slash ThejoinPaths([... '/', basepath, serverFns.base, '/' ])+cleanPathcollapse duplicate slashes and guarantee exactly one leading and trailing slash.@@ -1025,0 +1006,21 @@1006+ })1007+ if (this.options.rewrite) {1008+ this.rewrite = composeRewrites([1009+ basepathRewrite,1010+ this.options.rewrite,1011+ ])1012+ } else {1013+ this.rewrite = basepathRewrite1014+ }1015+ }1016+ } else if (this.options.rewrite !== this.rewrite) {1017+ needsLocationUpdate = true1018+ this.rewrite = this.options.rewrite1019+ }1020+ if (needsLocationUpdate) {1021+ this.__store.state = {1022+ ...this.state,1023+ location: this.latestLocation,1024+ }1025+ }1026+⚠️ Potential issue | 🔴 Critical
Basepath rewrite is lost after the first update On the first
router.update({ basepath })we compose the basepath rewrite correctly, but on the very nextupdate()(even if unrelated) theelse if (this.options.rewrite !== this.rewrite)branch fires becausethis.rewritenow holds the composed pair, so we replace it with only the user rewrite and drop the basepath transform. Navigations under a non-root basepath break immediately (e.g.router.update({ defaultPendingMs: 0 })after mounting under/appmakes the router read/write raw/app/...URLs again). Likewise, clearing the basepath (router.update({ basepath: undefined })) never removes the old transform, because theif (this.options.basepath)guard skips the reassignment, leavingthis.basepathandthis.rewritestuck on the stale value. Please recompute the final rewrite any time either option changes and allow the basepath to reset back to/.A minimal fix is to snapshot the previous options before the spread, compare them, and rebuild
this.rewrite(composing basepath + user rewrite when both are present) every time either value changes, then refreshlatestLocationwith the new rewrite:@@ - this.options = { - ...this.options, - ...newOptions, - } + const prevOptions = this.options + const prevBasepath = this.basepath ?? prevOptions?.basepath ?? '/' + const basepathWasUnset = this.basepath === undefined + const prevRewriteOption = prevOptions?.rewrite + + this.options = { + ...prevOptions, + ...newOptions, + } @@ - if (this.history) { - this.updateLatestLocation() - } + if (this.history) { + this.updateLatestLocation() + } @@ - let needsLocationUpdate = false - if (this.basepath !== this.options.basepath) { - needsLocationUpdate = true - if (this.options.basepath) { - this.basepath = this.options.basepath - const basepathRewrite = rewriteBasepath({ - basepath: this.basepath, - }) - if (this.options.rewrite) { - this.rewrite = composeRewrites([ - basepathRewrite, - this.options.rewrite, - ]) - } else { - this.rewrite = basepathRewrite - } - } - } else if (this.options.rewrite !== this.rewrite) { - needsLocationUpdate = true - this.rewrite = this.options.rewrite - } - if (needsLocationUpdate) { - this.__store.state = { - ...this.state, - location: this.latestLocation, - } - } + let needsLocationUpdate = false + const nextBasepath = this.options.basepath ?? '/' + const nextRewriteOption = this.options.rewrite + const basepathChanged = basepathWasUnset || prevBasepath !== nextBasepath + const rewriteChanged = prevRewriteOption !== nextRewriteOption + + if (basepathChanged || rewriteChanged) { + this.basepath = nextBasepath + + const rewrites: Array<LocationRewrite> = [] + if (trimPath(nextBasepath) !== '') { + rewrites.push( + rewriteBasepath({ + basepath: nextBasepath, + }), + ) + } + if (nextRewriteOption) { + rewrites.push(nextRewriteOption) + } + + this.rewrite = + rewrites.length === 0 + ? undefined + : rewrites.length === 1 + ? rewrites[0] + : composeRewrites(rewrites) + + if (this.history) { + this.updateLatestLocation() + } + + needsLocationUpdate = true + } + + if (needsLocationUpdate && this.__store) { + this.__store.state = { + ...this.state, + location: this.latestLocation, + } + }This keeps the basepath transform alive across subsequent updates, lets you remove it cleanly, and prevents stale
latestLocationdata after the rewrite changes.Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In packages/router-core/src/router.ts around lines 999 to 1026, the composed basepath rewrite is lost or becomes stale because we only set this.rewrite once and later replace it with the user rewrite; snapshot the previous options before applying the new ones, compare previous.basepath and previous.rewrite to this.options.basepath/this.options.rewrite, and whenever either changed recompute this.rewrite from scratch by building a fresh basepathRewrite (treat undefined/empty basepath as resetting to default/root) and then composing it with the user-provided rewrite when both exist (or using the single transform otherwise); update this.basepath to the new value, refresh this.latestLocation through the new rewrite, set needsLocationUpdate and assign this.__store.state.location to the refreshed latestLocation so the router always uses the correct composed transform and can both add and remove basepath correctly.✅ Addressed in commit f8e36da
apply this fix
@schiller-manuel, here's the fixed code implementing the suggested changes to properly handle basepath rewrite updates:
update: UpdateFn< TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated > = (newOptions) => { if (newOptions.notFoundRoute) { console.warn( 'The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info.', ) } const prevOptions = this.options const prevBasepath = this.basepath ?? prevOptions?.basepath ?? '/' const basepathWasUnset = this.basepath === undefined const prevRewriteOption = prevOptions?.rewrite this.options = { ...prevOptions, ...newOptions, } this.isServer = this.options.isServer ?? typeof document === 'undefined' this.pathParamsDecodeCharMap = this.options.pathParamsAllowedCharacters ? new Map( this.options.pathParamsAllowedCharacters.map((char) => [ encodeURIComponent(char), char, ]), ) : undefined if ( !this.history || (this.options.history && this.options.history !== this.history) ) { if (!this.options.history) { if (!this.isServer) { this.history = createBrowserHistory() as TRouterHistory } } else { this.history = this.options.history } } this.origin = this.options.origin if (!this.origin) { if (!this.isServer) { this.origin = window.origin } else { // fallback for the server, can be overridden by calling router.update({origin}) on the server this.origin = 'http://localhost' } } if (this.history) { this.updateLatestLocation() } if (this.options.routeTree !== this.routeTree) { this.routeTree = this.options.routeTree as TRouteTree this.buildRouteTree() } if (!this.__store && this.latestLocation) { this.__store = new Store(getInitialRouterState(this.latestLocation), { onUpdate: () => { this.__store.state = { ...this.state, cachedMatches: this.state.cachedMatches.filter( (d) => !['redirected'].includes(d.status), ), } }, }) setupScrollRestoration(this) } let needsLocationUpdate = false const nextBasepath = this.options.basepath ?? '/' const nextRewriteOption = this.options.rewrite const basepathChanged = basepathWasUnset || prevBasepath !== nextBasepath const rewriteChanged = prevRewriteOption !== nextRewriteOption if (basepathChanged || rewriteChanged) { this.basepath = nextBasepath const rewrites: Array<LocationRewrite> = [] if (trimPath(nextBasepath) !== '') { rewrites.push( rewriteBasepath({ basepath: nextBasepath, }), ) } if (nextRewriteOption) { rewrites.push(nextRewriteOption) } this.rewrite = rewrites.length === 0 ? undefined : rewrites.length === 1 ? rewrites[0] : composeRewrites(rewrites) if (this.history) { this.updateLatestLocation() } needsLocationUpdate = true } if (needsLocationUpdate && this.__store) { this.__store.state = { ...this.state, location: this.latestLocation, } } if ( typeof window !== 'undefined' && 'CSS' in window && typeof window.CSS?.supports === 'function' ) { this.isViewTransitionTypesSupported = window.CSS.supports( 'selector(:active-view-transition-type(a)', ) } }This fix ensures that:
- The basepath rewrite is preserved across multiple
router.update()calls - Both basepath and custom rewrite options are properly composed
- Clearing the basepath (
router.update({ basepath: undefined })) correctly resets to root - The location state is refreshed when either option changes
You can apply this code to replace the existing
updatemethod inpackages/router-core/src/router.ts.
🧠 Learnings used
Learnt from: schiller-manuel PR: TanStack/router#5330 File: packages/router-core/src/router.ts:2231-2245 Timestamp: 2025-10-01T18:30:26.559Z Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.packages/start-server-core/src/global.d.ts lines 4 to 5@@ -1,5 +1,5 @@11 declare global {22 namespace NodeJS {33 interface ProcessEnv {4- TSS_APP_BASE?: string5- TSS_SERVER_FN_BASE?: string4+ TSS_ROUTER_BASEPATH: string5+ TSS_SERVER_FN_BASE: string🛠️ Refactor suggestion | 🟠 Major
Required env vars need runtime validation.
Changing
TSS_ROUTER_BASEPATHandTSS_SERVER_FN_BASEfrom optional to required in the type system doesn't guarantee they're set at runtime. If these aren't provided,process.env.TSS_ROUTER_BASEPATHwill beundefineddespite the type declaring it asstring, leading to potential runtime errors.Consider adding runtime validation where these are first accessed (e.g., in
createStartHandler.tsline 57 andcreateClientRpc.tsline 5):const ROUTER_BASEPATH = process.env.TSS_ROUTER_BASEPATH if (!ROUTER_BASEPATH) { throw new Error('TSS_ROUTER_BASEPATH environment variable is required') }Similarly for
TSS_SERVER_FN_BASE:const SERVER_FN_BASE = process.env.TSS_SERVER_FN_BASE if (!SERVER_FN_BASE) { throw new Error('TSS_SERVER_FN_BASE environment variable is required') }🤖 Prompt for AI Agents
In packages/start-server-core/src/global.d.ts around lines 4 to 5, the env vars TSS_ROUTER_BASEPATH and TSS_SERVER_FN_BASE were made required in types but lack runtime checks; add runtime validation at the points they’re first accessed (e.g., in createStartHandler.ts at ~line 57 and createClientRpc.ts at ~line 5): read each value from process.env, verify it is a non-empty string, and throw a clear Error if missing so the runtime matches the type expectations and fails fast with an actionable message.schiller-manuel(GitHub profile, opens in a new tab)replied on
packages/router-core/src/router.tslines 1004 to 1045apply this fix
coderabbitai[bot](GitHub profile, opens in a new tab)replied on
packages/router-core/src/router.tslines 1004 to 1045@schiller-manuel, here's the fixed code implementing the suggested changes to properly handle basepath rewrite updates:
update: UpdateFn< TRouteTree, TTrailingSlashOption, TDefaultStructuralSharingOption, TRouterHistory, TDehydrated > = (newOptions) => { if (newOptions.notFoundRoute) { console.warn( 'The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info.', ) } const prevOptions = this.options const prevBasepath = this.basepath ?? prevOptions?.basepath ?? '/' const basepathWasUnset = this.basepath === undefined const prevRewriteOption = prevOptions?.rewrite this.options = { ...prevOptions, ...newOptions, } this.isServer = this.options.isServer ?? typeof document === 'undefined' this.pathParamsDecodeCharMap = this.options.pathParamsAllowedCharacters ? new Map( this.options.pathParamsAllowedCharacters.map((char) => [ encodeURIComponent(char), char, ]), ) : undefined if ( !this.history || (this.options.history && this.options.history !== this.history) ) { if (!this.options.history) { if (!this.isServer) { this.history = createBrowserHistory() as TRouterHistory } } else { this.history = this.options.history } } this.origin = this.options.origin if (!this.origin) { if (!this.isServer) { this.origin = window.origin } else { // fallback for the server, can be overridden by calling router.update({origin}) on the server this.origin = 'http://localhost' } } if (this.history) { this.updateLatestLocation() } if (this.options.routeTree !== this.routeTree) { this.routeTree = this.options.routeTree as TRouteTree this.buildRouteTree() } if (!this.__store && this.latestLocation) { this.__store = new Store(getInitialRouterState(this.latestLocation), { onUpdate: () => { this.__store.state = { ...this.state, cachedMatches: this.state.cachedMatches.filter( (d) => !['redirected'].includes(d.status), ), } }, }) setupScrollRestoration(this) } let needsLocationUpdate = false const nextBasepath = this.options.basepath ?? '/' const nextRewriteOption = this.options.rewrite const basepathChanged = basepathWasUnset || prevBasepath !== nextBasepath const rewriteChanged = prevRewriteOption !== nextRewriteOption if (basepathChanged || rewriteChanged) { this.basepath = nextBasepath const rewrites: Array<LocationRewrite> = [] if (trimPath(nextBasepath) !== '') { rewrites.push( rewriteBasepath({ basepath: nextBasepath, }), ) } if (nextRewriteOption) { rewrites.push(nextRewriteOption) } this.rewrite = rewrites.length === 0 ? undefined : rewrites.length === 1 ? rewrites[0] : composeRewrites(rewrites) if (this.history) { this.updateLatestLocation() } needsLocationUpdate = true } if (needsLocationUpdate && this.__store) { this.__store.state = { ...this.state, location: this.latestLocation, } } if ( typeof window !== 'undefined' && 'CSS' in window && typeof window.CSS?.supports === 'function' ) { this.isViewTransitionTypesSupported = window.CSS.supports( 'selector(:active-view-transition-type(a)', ) } }This fix ensures that:
- The basepath rewrite is preserved across multiple
router.update()calls - Both basepath and custom rewrite options are properly composed
- Clearing the basepath (
router.update({ basepath: undefined })) correctly resets to root - The location state is refreshed when either option changes
You can apply this code to replace the existing
updatemethod inpackages/router-core/src/router.ts.
🧠 Learnings used
Learnt from: schiller-manuel PR: TanStack/router#5330 File: packages/router-core/src/router.ts:2231-2245 Timestamp: 2025-10-01T18:30:26.559Z Learning: In `packages/router-core/src/router.ts`, the `resolveRedirect` method intentionally strips the router's origin from redirect URLs when they match (e.g., `https://foo.com/bar` → `/bar` for same-origin redirects) while preserving the full URL for cross-origin redirects. This logic should not be removed or simplified to use `location.publicHref` directly.- The basepath rewrite is preserved across multiple
More templates
- tanstack-router-solid-example-basic
- 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-streaming-file-based
- tanstack-router-solid-example-kitchen-sink-file-based
- tanstack-router-solid-example-quickstart-file-based
- tanstack-solid-start-example-bare
- tanstack-solid-start-example-basic
- tanstack-solid-start-example-basic-static
- 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-start-example-basic-cloudflare
- tanstack-start-example-basic-react-query
- tanstack-start-example-basic-static
- tanstack-start-bun-hosting
- tanstack-start-example-convex-trellaux
- tanstack-start-example-counter
- tanstack-start-i18n-paraglide
- tanstack-start-example-large
- tanstack-start-example-material-ui
- 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@5345@tanstack/directive-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/directive-functions-plugin@5345@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/eslint-plugin-router@5345@tanstack/history
npm i https://pkg.pr.new/TanStack/router/@tanstack/history@5345@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/nitro-v2-vite-plugin@5345@tanstack/react-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router@5345@tanstack/react-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-devtools@5345@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-router-ssr-query@5345@tanstack/react-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start@5345@tanstack/react-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-client@5345@tanstack/react-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/react-start-server@5345@tanstack/router-cli
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-cli@5345@tanstack/router-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-core@5345@tanstack/router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools@5345@tanstack/router-devtools-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-devtools-core@5345@tanstack/router-generator
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-generator@5345@tanstack/router-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-plugin@5345@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-ssr-query-core@5345@tanstack/router-utils
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-utils@5345@tanstack/router-vite-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/router-vite-plugin@5345@tanstack/server-functions-plugin
npm i https://pkg.pr.new/TanStack/router/@tanstack/server-functions-plugin@5345@tanstack/solid-router
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router@5345@tanstack/solid-router-devtools
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-router-devtools@5345@tanstack/solid-start
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start@5345@tanstack/solid-start-client
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-client@5345@tanstack/solid-start-server
npm i https://pkg.pr.new/TanStack/router/@tanstack/solid-start-server@5345@tanstack/start-client-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-client-core@5345@tanstack/start-plugin-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-plugin-core@5345@tanstack/start-server-core
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-server-core@5345@tanstack/start-static-server-functions
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-static-server-functions@5345@tanstack/start-storage-context
npm i https://pkg.pr.new/TanStack/router/@tanstack/start-storage-context@5345@tanstack/valibot-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/valibot-adapter@5345@tanstack/virtual-file-routes
npm i https://pkg.pr.new/TanStack/router/@tanstack/virtual-file-routes@5345@tanstack/zod-adapter
npm i https://pkg.pr.new/TanStack/router/@tanstack/zod-adapter@5345commit:
7b1b684github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: nitro-v2-vite-plugin
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/start-plugin-core/src/prerender.ts (1)
141-141: HoistrouterBasePathoutside the loop for efficiency.The
routerBasePathis recomputed for every page insideaddCrawlPageTask, butstartConfig.router.basepathremains constant throughout the prerender operation. Declare it once in theprerenderPagesfunction scope to avoid redundant computations.Apply this diff:
async function prerenderPages({ outputDir }: { outputDir: string }) { const seen = new Set<string>() const retriesByPath = new Map<string, number>() const concurrency = startConfig.prerender?.concurrency ?? os.cpus().length logger.info(`Concurrency: ${concurrency}`) const queue = new Queue({ concurrency }) + const routerBasePath = joinURL('/', startConfig.router.basepath ?? '') startConfig.pages.forEach((page) => addCrawlPageTask(page)) await queue.start() return Array.from(seen) function addCrawlPageTask(page: Page) { // Was the page already seen? if (seen.has(page.path)) return // Add the page to the seen set seen.add(page.path) if (page.fromCrawl) { startConfig.pages.push(page) } // If not enabled, skip if (!(page.prerender?.enabled ?? true)) return // If there is a filter link, check if the page should be prerendered if (startConfig.prerender?.filter && !startConfig.prerender.filter(page)) return // Resolve the merged default and page-specific prerender options const prerenderOptions = { ...startConfig.prerender, ...page.prerender, } - const routerBasePath = joinURL('/', startConfig.router.basepath ?? '') - // Add the taskpackages/nitro-v2-vite-plugin/src/index.ts (1)
10-17: Consider extractingisFullUrlto a shared utility.The
isFullUrlhelper is duplicated across multiple packages (also present instart-plugin-core). If these packages share a common utilities package, consider extracting this function to reduce duplication and ensure consistent behavior.If a shared utilities package exists (e.g.,
@tanstack/start-utils), extract the helper:// In shared utils package export function isFullUrl(str: string): boolean { try { new URL(str) return true } catch { return false } }Then import it in both files:
+import { isFullUrl } from '@tanstack/start-utils' + -function isFullUrl(str: string): boolean { - try { - new URL(str) - return true - } catch { - return false - } -}📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between fa41d59c88ce62fe335e14e94a60f562e3d99a01 and c79ff93d80e574f34ff931d87a701261fccad31e.
📒 Files selected for processing (4)
packages/nitro-v2-vite-plugin/src/index.ts(3 hunks)packages/react-router/tests/router.test.tsx(11 hunks)packages/start-plugin-core/src/plugin.ts(6 hunks)packages/start-plugin-core/src/prerender.ts(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/start-plugin-core/src/plugin.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/start-plugin-core/src/prerender.tspackages/react-router/tests/router.test.tsxpackages/nitro-v2-vite-plugin/src/index.ts
packages/{*-start,start-*}/**
📄 CodeRabbit inference engine (AGENTS.md)
Name and place Start framework packages under packages/-start/ or packages/start-/
Files:
packages/start-plugin-core/src/prerender.ts
packages/{react-router,solid-router}/**
📄 CodeRabbit inference engine (AGENTS.md)
Implement React and Solid bindings/components only in packages/react-router/ and packages/solid-router/
Files:
packages/react-router/tests/router.test.tsx
🧬 Code graph analysis (1)
packages/nitro-v2-vite-plugin/src/index.ts (1)
packages/start-plugin-core/src/plugin.ts (1)
config(104-306)
⏰ 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). (2)
- GitHub Check: Preview
- GitHub Check: Test
🔇 Additional comments (4)
packages/react-router/tests/router.test.tsx (1)
2604-3005: LGTM! Comprehensive test coverage for basepath functionality.The new test suite thoroughly covers the
basepathoption across multiple scenarios:- Basic basepath rewriting (stripping on input)
- Various basepath formats (with/without leading/trailing slashes)
- Edge cases (empty basepath, trailing slash mismatches)
- Composition with additional rewrite logic
- Preservation of search params and hash
- Output rewriting (adding basepath back on navigation)
- Nested rewrites with multiple layers
The parameterized tests using
it.eacheffectively validate that basepath works consistently regardless of slash conventions, which is a common source of bugs.packages/nitro-v2-vite-plugin/src/index.ts (3)
10-17: LGTM!The
isFullUrlhelper correctly identifies absolute URLs using the URL constructor. The try-catch pattern handles all edge cases appropriately (empty strings, relative paths, protocol-relative URLs).
20-20: Use a definite assignment assertion for resolvedConfig TypeScript’s strictPropertyInitialization may flag the uninitialized declaration—change tolet resolvedConfig!: ResolvedConfigor disable
strictPropertyInitializationin your tsconfig.
97-108: Review nitroConfig spread orderingThe spread of
...nitroConfigcurrently followsbaseURLandpublicAssets, so user settings will override those computed defaults. If defaults should take precedence, move the spread above them; otherwise document or warn when overrides occur.packages/nitro-v2-vite-plugin/src/index.ts (around line 108)
Suggested change:
const config: NitroConfig = { + ...nitroConfig, baseURL, publicAssets: [ { dir: client.config.build.outDir, maxAge: 31536000 }, ], - ...nitroConfig, renderer: virtualEntry, }Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/nitro-v2-vite-plugin/src/index.ts (1)
10-17: Consider extractingisFullUrlto a shared utility module.This function is duplicated in
packages/start-plugin-core/src/plugin.ts(line 103). To adhere to DRY principles, consider extracting it to a shared utility module that both packages can import.packages/start-plugin-core/src/plugin.ts (1)
52-59: ExtractisFullUrlinto a shared utility Identical implementations exist inpackages/start-plugin-core/src/plugin.tsandpackages/nitro-v2-vite-plugin/src/index.ts; centralize this helper to adhere to DRY principles.📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between c79ff93d80e574f34ff931d87a701261fccad31e and 02c743bcca5ff3c43aff7a0d12950b75decdeb45.
📒 Files selected for processing (2)
packages/nitro-v2-vite-plugin/src/index.ts(3 hunks)packages/start-plugin-core/src/plugin.ts(6 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/start-plugin-core/src/plugin.tspackages/nitro-v2-vite-plugin/src/index.ts
packages/{*-start,start-*}/**
📄 CodeRabbit inference engine (AGENTS.md)
Name and place Start framework packages under packages/-start/ or packages/start-/
Files:
packages/start-plugin-core/src/plugin.ts
🧬 Code graph analysis (2)
packages/start-plugin-core/src/plugin.ts (1)
packages/start-plugin-core/src/schema.ts (1)
TanStackStartOutputConfig(202-202)
packages/nitro-v2-vite-plugin/src/index.ts (1)
packages/start-plugin-core/src/plugin.ts (1)
config(104-313)
⏰ 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)
- GitHub Check: Test
🔇 Additional comments (9)
packages/nitro-v2-vite-plugin/src/index.ts (2)
20-20: Verify hook execution order or guardresolvedConfigusage.No references were found in the repo confirming that
configResolvedalways runs before thebuildAppcallback. Please manually verify Vite’s lifecycle for your version or add a runtime check before usingresolvedConfigto prevent undefined access.
97-109: Review config override and publicAssets baseURL- user-provided nitroConfig.baseURL overrides the computed baseURL due to spread order; swap them if the computed value should take precedence.
- publicAssets.baseURL is hardcoded to
'/'and may conflict with a non-root base path; either align it to the computed baseURL or document why it must remain'/'.
packages/start-plugin-core/src/plugin.ts (7)
1-1: LGTM!The import of
joinPathsis necessary for the new path normalization logic introduced in this PR.
44-44: LGTM!The
viteAppBaseproperty is properly typed and integrated into the configuration flow.
70-70: LGTM!The empty string default is appropriate and will be overridden during configuration resolution.
126-131: LGTM!The computation correctly derives the server function base path from the router basepath and serverFns base, ensuring consistent path handling throughout the application.
338-341: LGTM!The refactoring to pass
getConfiginstead of individual parameters improves maintainability and consistency with other plugins likedevServerPlugin.
280-282: Migration verified: no remainingTSS_APP_BASEreferences Ripgrep search returned no hits in.ts/.tsx.
117-124: Default/basepath becoming''is treated as root and works correctly.packages/start-plugin-core/src/plugin.ts lines 105 to 112@@ -90,6 +102,11 @@90102 name: 'tanstack-start-core:config',91103 enforce: 'pre',92104 async config(viteConfig, { command }) {93- const viteAppBase = trimPathRight(viteConfig.base || '/')94- globalThis.TSS_APP_BASE = viteAppBase95-105+ resolvedStartConfig.viteAppBase = viteConfig.base ?? '/'106+ if (!isFullUrl(resolvedStartConfig.viteAppBase)) {107+ resolvedStartConfig.viteAppBase = joinPaths([108+ '/',109+ viteConfig.base,110+ '/',111+ ])112+ }🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
Verify handling of empty string base path.
The logic correctly distinguishes between full URLs and relative paths. However, if
viteConfig.baseis explicitly set to an empty string (''), it will be normalized to'/'. Ensure this behavior aligns with Vite's base path handling conventions.Run the following script to check Vite's default base handling:
🌐 Web query:
What is the default value and behavior of Vite's config.base option when set to an empty string?💡 Result:
Default is "/". Setting config.base to an empty string (or "./") tells Vite to use a relative (embedded) public base path so built asset URLs are generated relative to the current HTML file (suitable for embedded/static deployments). import.meta.env.BASE_URL will reflect that relative value. [1][2]
Sources: [1] Vite config (base option). [2] Vite — Public Base Path / Building for Production.
🏁 Script executed:
#!/bin/bash rg -n "joinPaths" -C3 --type=tsLength of output: 9666
🏁 Script executed:
#!/bin/bash sed -n '1,100p' packages/router-core/src/path.tsLength of output: 2691
Handle explicit empty-string base path. Vite treats
base: ""as a relative./public path, but hereviteConfig.base === ""is normalized to/. Add a guard before the URL check to setresolvedStartConfig.viteAppBase = "./"whenviteConfig.base === "".🤖 Prompt for AI Agents
In packages/start-plugin-core/src/plugin.ts around lines 105 to 112, add a guard for the explicit empty-string base: if viteConfig.base === "" set resolvedStartConfig.viteAppBase = "./" before the URL check; otherwise continue with the existing logic that sets viteAppBase to viteConfig.base ?? '/' and falls back to joinPaths when not a full URL. This ensures Vite's empty-string base is preserved as a relative "./" path instead of being normalized to "/".Actionable comments posted: 0
♻️ Duplicate comments (1)
packages/start-plugin-core/src/plugin.ts (1)
105-124: Preserve explicit empty-string Vite base.Vite treats
config.base === ''as the special embedded-relative./base, but the normalization here collapses it back to'/', so relative deployments andimport.meta.env.BASE_URL === './'break. Please keep the empty-string case intact (setviteAppBaseto'./') and translate that to an empty router basepath instead of'.'.- resolvedStartConfig.viteAppBase = viteConfig.base ?? '/' - if (!isFullUrl(resolvedStartConfig.viteAppBase)) { - resolvedStartConfig.viteAppBase = joinPaths([ - '/', - viteConfig.base, - '/', - ]) - } + const rawViteBase = viteConfig.base ?? '/' + if (viteConfig.base === '') { + resolvedStartConfig.viteAppBase = './' + } else if (!isFullUrl(rawViteBase)) { + resolvedStartConfig.viteAppBase = joinPaths([ + '/', + rawViteBase, + '/', + ]) + } else { + resolvedStartConfig.viteAppBase = rawViteBase + } @@ - if (!isFullUrl(resolvedStartConfig.viteAppBase)) { - startConfig.router.basepath = - resolvedStartConfig.viteAppBase.replace(/^\/|\/$/g, '') + if (!isFullUrl(resolvedStartConfig.viteAppBase)) { + const normalizedBase = resolvedStartConfig.viteAppBase.replace( + /^\/|\/$/g, + '', + ) + startConfig.router.basepath = + normalizedBase === '.' ? '' : normalizedBase } else { startConfig.router.basepath = '/' }🧹 Nitpick comments (1)
packages/nitro-v2-vite-plugin/src/index.ts (1)
20-20: Consider initializingresolvedConfigor using definite assignment assertion.In TypeScript strict mode,
resolvedConfigis declared but not initialized. While Vite's lifecycle guaranteesconfigResolvedruns beforebuildApp, the type system doesn't know this.Apply one of these approaches:
Option 1: Definite assignment assertion (if you're certain about the lifecycle)
- let resolvedConfig: ResolvedConfig + let resolvedConfig!: ResolvedConfigOption 2: Defensive check in buildApp
async buildApp(builder) { + if (!resolvedConfig) { + throw new Error('configResolved hook must run before buildApp') + } const client = builder.environments.clientAlso applies to: 55-57
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 02c743bcca5ff3c43aff7a0d12950b75decdeb45 and 9f71f75c72cfefbf28842e7b03185daebcbfd4c1.
📒 Files selected for processing (3)
packages/nitro-v2-vite-plugin/src/index.ts(3 hunks)packages/start-plugin-core/src/plugin.ts(6 hunks)packages/start-plugin-core/src/prerender.ts(3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/start-plugin-core/src/prerender.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Use TypeScript in strict mode with extensive type safety across the codebase
Files:
packages/nitro-v2-vite-plugin/src/index.tspackages/start-plugin-core/src/plugin.ts
packages/{*-start,start-*}/**
📄 CodeRabbit inference engine (AGENTS.md)
Name and place Start framework packages under packages/-start/ or packages/start-/
Files:
packages/start-plugin-core/src/plugin.ts
🧬 Code graph analysis (1)
packages/start-plugin-core/src/plugin.ts (1)
packages/start-plugin-core/src/schema.ts (1)
TanStackStartOutputConfig(202-202)
🔇 Additional comments (4)
packages/nitro-v2-vite-plugin/src/index.ts (4)
4-4: LGTM!The addition of
ResolvedConfigto the imports is necessary for the newconfigResolvedhook.
10-17: LGTM!The
isFullUrlhelper correctly uses the URL constructor to detect absolute URLs. The try-catch pattern appropriately handles theTypeErrorthrown for relative URLs.
97-99: LGTM!The logic correctly filters out absolute URLs (e.g., from CDN configurations) and only uses relative base paths as the Nitro
baseURL.
100-121: Verify thatpublicAssetsoverride behavior is intentional.The current structure allows
nitroConfigto completely override thepublicAssetsarray (which includes the client build output). If a user provides their ownpublicAssets, the client assets might not be served correctly.Consider whether you should merge the arrays instead:
const config: NitroConfig = { baseURL, - publicAssets: [ - { - dir: client.config.build.outDir, - maxAge: 31536000, // 1 year - baseURL: '/', - }, - ], ...nitroConfig, + publicAssets: [ + { + dir: client.config.build.outDir, + maxAge: 31536000, // 1 year + baseURL: '/', + }, + ...(nitroConfig?.publicAssets ?? []), + ], renderer: virtualEntry,This ensures the client assets are always served while allowing users to add additional public assets.
Sign in to join this conversation.
Walkthrough#
Removes the exported rewriteBasepath and migrates basepath handling into runtime/router options and plugin config. Updates Vite/Nitro/start plugins, client/server RPC and manifest flows, tests, and example Vite base setting to use the new basepath/environment variables and normalized config plumbing.
Changes#
packages/react-router/src/index.tsx,packages/solid-router/src/index.tsx,packages/router-core/src/index.tsrewriteBasepath; continue exportingcomposeRewrites.packages/router-core/src/router.tspackages/react-router/tests/router.test.tsxrewriteBasepathusage withbasepathrouter option; parameterize tests across basepath forms and adjust scenarios.packages/start-client-core/src/client/hydrateStart.ts,packages/start-client-core/src/client-rpc/createClientRpc.tsrouter.updateincludingbasepathand serialization adapters; simplify client RPC URL toprocess.env.TSS_SERVER_FN_BASE + functionId.packages/start-plugin-core/src/plugin.ts,.../start-manifest-plugin/plugin.ts,.../schema.ts,.../prerender.ts,.../global.d.tsviteAppBaseto resolved config, deriverouter.basepath, compute/injectTSS_SERVER_FN_BASEandTSS_ROUTER_BASEPATH, extend schema withrouter.basepath, replaceTSS_APP_BASEusage with router basepath, addgetConfigto start-manifest plugin.packages/start-server-core/src/createStartHandler.ts,.../createServerRpc.ts,.../request-response.ts,.../router-manifest.ts,.../server-functions-handler.ts,.../global.d.tsTSS_ROUTER_BASEPATHand requireTSS_SERVER_FN_BASE; simplify RPC URL construction; remove h3_toResponse conversion;getStartManifest()no longer takes args; lazy regex for server-fn parsing; add router.update basepath on init.packages/nitro-v2-vite-plugin/src/index.tsconfigResolved, detect full URLs, and set top-level NitrobaseURLfrom Vitebasewhen relative.examples/react/start-basic/vite.config.tsbaseto/foo/.Sequence Diagram(s)#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~75 minutes
Possibly related PRs#
Suggested reviewers#
Poem#
Pre-merge checks and finishing touches#
❌ Failed checks (1 warning, 1 inconclusive)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 9f71f75c72cfefbf28842e7b03185daebcbfd4c1 and 3e225196bee8a5fc21af93f0e3d36474cd5c76c3.
📒 Files selected for processing (1)
packages/start-plugin-core/src/plugin.ts(6 hunks)🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
Files:
packages/start-plugin-core/src/plugin.tspackages/{*-start,start-*}/**
📄 CodeRabbit inference engine (AGENTS.md)
Files:
packages/start-plugin-core/src/plugin.ts🧬 Code graph analysis (1)
packages/start-plugin-core/src/plugin.ts (1)
⏰ 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). (2)
🔇 Additional comments (6)
Comment `@coderabbitai help` to get the list of available commands and usage tips.