feat: support split base and basepath in TanStack Start dev server #6792
main fromrefs/pull/6792/head·merged by schiller-manuel(GitHub profile, opens in a new tab) Summary by CodeRabbit#
New Features
- Added support for split base and basepath in React e2e project and a dev middleware to transparently rewrite URLs when bases differ.
Bug Fixes
- Resolved runtime error caused by misaligned router basepath and dev server base.
Tests
- Added comprehensive end-to-end Playwright tests validating SSR, asset paths, and client navigation.
Chores
- Removed an unused emitted build-time global and added project scaffolding, configuration, and dependency version updates.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-plugin-core
View your CI Pipeline Execution ↗ for commit bec31344ad0aa3a3602202bb305ad3fa6763ea8c
Command Status Duration Result nx run tanstack-router-e2e-bundle-size:build --...✅ Succeeded 1m 26s View ↗
☁️ Nx Cloud last updated this comment at
2026-03-01 17:33:05UTCMore 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-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-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/arktype-adapter
npm i https://pkg.pr.new/@tanstack/arktype-adapter@6792@tanstack/eslint-plugin-router
npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@6792@tanstack/history
npm i https://pkg.pr.new/@tanstack/history@6792@tanstack/nitro-v2-vite-plugin
npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@6792@tanstack/react-router
npm i https://pkg.pr.new/@tanstack/react-router@6792@tanstack/react-router-devtools
npm i https://pkg.pr.new/@tanstack/react-router-devtools@6792@tanstack/react-router-ssr-query
npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@6792@tanstack/react-start
npm i https://pkg.pr.new/@tanstack/react-start@6792@tanstack/react-start-client
npm i https://pkg.pr.new/@tanstack/react-start-client@6792@tanstack/react-start-server
npm i https://pkg.pr.new/@tanstack/react-start-server@6792@tanstack/router-cli
npm i https://pkg.pr.new/@tanstack/router-cli@6792@tanstack/router-core
npm i https://pkg.pr.new/@tanstack/router-core@6792@tanstack/router-devtools
npm i https://pkg.pr.new/@tanstack/router-devtools@6792@tanstack/router-devtools-core
npm i https://pkg.pr.new/@tanstack/router-devtools-core@6792@tanstack/router-generator
npm i https://pkg.pr.new/@tanstack/router-generator@6792@tanstack/router-plugin
npm i https://pkg.pr.new/@tanstack/router-plugin@6792@tanstack/router-ssr-query-core
npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@6792@tanstack/router-utils
npm i https://pkg.pr.new/@tanstack/router-utils@6792@tanstack/router-vite-plugin
npm i https://pkg.pr.new/@tanstack/router-vite-plugin@6792@tanstack/solid-router
npm i https://pkg.pr.new/@tanstack/solid-router@6792@tanstack/solid-router-devtools
npm i https://pkg.pr.new/@tanstack/solid-router-devtools@6792@tanstack/solid-router-ssr-query
npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@6792@tanstack/solid-start
npm i https://pkg.pr.new/@tanstack/solid-start@6792@tanstack/solid-start-client
npm i https://pkg.pr.new/@tanstack/solid-start-client@6792@tanstack/solid-start-server
npm i https://pkg.pr.new/@tanstack/solid-start-server@6792@tanstack/start-client-core
npm i https://pkg.pr.new/@tanstack/start-client-core@6792@tanstack/start-fn-stubs
npm i https://pkg.pr.new/@tanstack/start-fn-stubs@6792@tanstack/start-plugin-core
npm i https://pkg.pr.new/@tanstack/start-plugin-core@6792@tanstack/start-server-core
npm i https://pkg.pr.new/@tanstack/start-server-core@6792@tanstack/start-static-server-functions
npm i https://pkg.pr.new/@tanstack/start-static-server-functions@6792@tanstack/start-storage-context
npm i https://pkg.pr.new/@tanstack/start-storage-context@6792@tanstack/valibot-adapter
npm i https://pkg.pr.new/@tanstack/valibot-adapter@6792@tanstack/virtual-file-routes
npm i https://pkg.pr.new/@tanstack/virtual-file-routes@6792@tanstack/vue-router
npm i https://pkg.pr.new/@tanstack/vue-router@6792@tanstack/vue-router-devtools
npm i https://pkg.pr.new/@tanstack/vue-router-devtools@6792@tanstack/vue-router-ssr-query
npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@6792@tanstack/vue-start
npm i https://pkg.pr.new/@tanstack/vue-start@6792@tanstack/vue-start-client
npm i https://pkg.pr.new/@tanstack/vue-start-client@6792@tanstack/vue-start-server
npm i https://pkg.pr.new/@tanstack/vue-start-server@6792@tanstack/zod-adapter
npm i https://pkg.pr.new/@tanstack/zod-adapter@6792commit:
c5ff07bBundle Size Benchmarks#
- Commit:
5a625b2f5208 - Measured at:
2026-03-01T17:25:07.258Z - Baseline source:
history:e979285ebbc8 - Dashboard: bundle-size history
Scenario Current (gzip) Delta vs baseline Raw Brotli Trend react-router.minimal86.58 KiB 0 B (0.00%) 272.45 KiB 75.22 KiB ▁▁▁▇▇██████ react-router.full89.61 KiB 0 B (0.00%) 282.78 KiB 77.90 KiB ▁▁▁▇▇██████ solid-router.minimal35.88 KiB 0 B (0.00%) 107.56 KiB 32.26 KiB ▁▁▁▆▆██████ solid-router.full40.21 KiB 0 B (0.00%) 120.61 KiB 36.13 KiB ▁▁▁▆▆██████ vue-router.minimal51.75 KiB 0 B (0.00%) 147.54 KiB 46.50 KiB ▁▁▁▆▆██████ vue-router.full56.55 KiB 0 B (0.00%) 163.12 KiB 50.86 KiB ▁▁▁▅▅██████ react-start.minimal99.11 KiB 0 B (0.00%) 311.58 KiB 85.68 KiB ▁▁▁▅▅██████ react-start.full102.50 KiB 0 B (0.00%) 321.39 KiB 88.63 KiB ▁▁▁▅▅▇▇▇▇▇█ solid-start.minimal48.19 KiB 0 B (0.00%) 145.13 KiB 42.67 KiB ▁▁▁▆▆██████ solid-start.full53.68 KiB 0 B (0.00%) 161.08 KiB 47.37 KiB ▁▁▁▆▆▇▇▇▇▇█ Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.
- Commit:
Actionable comments posted: 3
🧹 Nitpick comments (1)
e2e/react-start/split-base-and-basepath/playwright.config.ts (1)
21-27: Remove duplicatedPORTinjection in prod command.webServer.env.PORTalready provides the variable; keeping it only there reduces command-string coupling.♻️ Suggested patch
webServer: { - command: isDev ? `pnpm dev:e2e` : `pnpm build && PORT=${PORT} pnpm start`, + command: isDev ? `pnpm dev:e2e` : `pnpm build && pnpm start`, url: baseURL, reuseExistingServer: !process.env.CI, stdout: 'pipe',🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@e2e/react-start/split-base-and-basepath/playwright.config.ts` around lines 21 - 27, The prod command in the Playwright webServer config duplicates PORT by embedding PORT=${PORT} in the "command" string while "env" already sets PORT; update the "command" property used when isDev is false to remove the embedded PORT=${PORT} so it relies on the webServer.env.PORT value (locate the "command" property and the webServer "env" object in playwright.config.ts and remove the PORT injection from the non-dev command).🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed. Inline comments: In `@e2e/react-start/split-base-and-basepath/package.json`: - Around line 18-26: The package.json shows a runtime dependency "express" at v4 while devDependencies use "@types/express" v5 causing type mismatches; update the dependency pair so their major versions match—either change "@types/express" to a v4 release (e.g., ^4.x) to match "express": "^4.21.2", or upgrade "express" to v5 and set "@types/express" to the corresponding v5; apply the same alignment to any other e2e fixture package.json files that list "express" and "@types/express". In `@e2e/react-start/split-base-and-basepath/tests/app.spec.ts`: - Around line 12-14: The test currently parses HTML from the fetch without first asserting the HTTP response succeeded; add an explicit success assertion immediately after `const response = await request.get('/')` (for example `ok(response.ok)` or `assert.strictEqual(response.status, 200)`) so request failures surface as a clear test/setup error before `const html = await response.text()` and downstream regex/assert noise; update the test near the `request.get('/')` call to perform this check. In `@packages/start-plugin-core/src/plugin.ts`: - Around line 413-415: The rewrite logic that prefixes req.url with base can double-prefix when req.url already equals the base root with or without a trailing slash or query (e.g., "/_ui" or "/_ui?x=1"); update the check to normalize base (e.g., let normalizedBase = base.replace(/\/$/, '')) and only prefix when req.url does not already start with normalizedBase nor normalizedBase + '/' nor equal normalizedBase (and handle query strings implicitly), i.e., replace the current if (req.url && !req.url.startsWith(base)) { ... } with a comparison against the normalizedBase variants using the existing req.url and base symbols so URLs at the base root are not rewritten. --- Nitpick comments: In `@e2e/react-start/split-base-and-basepath/playwright.config.ts`: - Around line 21-27: The prod command in the Playwright webServer config duplicates PORT by embedding PORT=${PORT} in the "command" string while "env" already sets PORT; update the "command" property used when isDev is false to remove the embedded PORT=${PORT} so it relies on the webServer.env.PORT value (locate the "command" property and the webServer "env" object in playwright.config.ts and remove the PORT injection from the non-dev command).
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 5a625b2f520857ac5fcf3782b59380b296eca030 and 7cd49b6a17e597f3b9f63d2f0012e94c01b85f7e.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (16)
e2e/react-start/import-protection/vite.config.tse2e/react-start/split-base-and-basepath/.gitignoree2e/react-start/split-base-and-basepath/.prettierignoree2e/react-start/split-base-and-basepath/package.jsone2e/react-start/split-base-and-basepath/playwright.config.tse2e/react-start/split-base-and-basepath/prod-server.jse2e/react-start/split-base-and-basepath/src/routeTree.gen.tse2e/react-start/split-base-and-basepath/src/router.tsxe2e/react-start/split-base-and-basepath/src/routes/__root.tsxe2e/react-start/split-base-and-basepath/src/routes/about.tsxe2e/react-start/split-base-and-basepath/src/routes/index.tsxe2e/react-start/split-base-and-basepath/src/styles/app.csse2e/react-start/split-base-and-basepath/tests/app.spec.tse2e/react-start/split-base-and-basepath/tsconfig.jsone2e/react-start/split-base-and-basepath/vite.config.tspackages/start-plugin-core/src/plugin.ts
💤 Files with no reviewable changes (1)
- e2e/react-start/import-protection/vite.config.ts
@@ -0,0 +6,21 @@6+ "scripts": {7+ "dev": "vite dev --port 3000",8+ "dev:e2e": "vite dev --port $PORT",9+ "build": "vite build && tsc --noEmit",10+ "start": "node prod-server.js",11+ "test:e2e:dev": "MODE=dev playwright test --project=chromium",12+ "test:e2e:prod": "playwright test --project=chromium",13+ "test:e2e": "rm -rf port*.txt; pnpm run test:e2e:dev && pnpm run test:e2e:prod"14+ },15+ "dependencies": {16+ "@tanstack/react-router": "workspace:^",17+ "@tanstack/react-start": "workspace:^",18+ "express": "^4.21.2",19+ "react": "^19.0.0",20+ "react-dom": "^19.0.0"21+ },22+ "devDependencies": {23+ "@playwright/test": "^1.50.1",24+ "@tanstack/router-e2e-utils": "workspace:^",25+ "@types/express": "^5.0.3",26+ "@types/node": "^22.10.2",⚠️ Potential issue | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
# First, read the specific package.json file to confirm the versions cat e2e/react-start/split-base-and-basepath/package.jsonRepository: TanStack/router
Length of output: 1149
🏁 Script executed:
# Run the verification script from the review comment cd /root/repo && python - <<'PY' import json, pathlib, re def major(v: str): m = re.search(r'(\d+)', v or '') return int(m.group(1)) if m else None for p in pathlib.Path('e2e').rglob('package.json'): data = json.loads(p.read_text()) deps = data.get('dependencies', {}) dev = data.get('devDependencies', {}) if 'express' in deps and '@types/express' in dev: ex = deps['express'] ty = dev['@types/express'] status = "OK" if major(ex) == major(ty) else "MISMATCH" print(f"{p}: express={ex}, `@types/express`={ty} => {status}") PYRepository: TanStack/router
Length of output: 119
🌐 Web query:
Express v4 compatibility with@types/expressv5 DefinitelyTyped💡 Result:
@types/express@5.xis intended to model Express 5, and it pulls in the Express-5-flavored core types (@types/express-serve-static-core@^5.0.0). That makes it a bad match for an Express 4 runtime (you can get type errors or “it compiles but doesn’t reflect v4 behavior”). [1]What to do if you’re on Express 4
- Pin the v4 type line explicitly (don’t rely on
latest):npm i -D@types/express@4.17.23(or any4.17.x) [2]
- If you pin transitive types, keep them on the v4 line too (e.g.
@types/express-serve-static-core@4.x), because the v5@types/expressdepends on@types/express-serve-static-core@^5.0.0. [1]
If you actually want
@types/express@5- Upgrade runtime to Express 5 and follow the Express 5 migration guidance for breaking changes. [3]
References: [1] DefinitelyTyped
@types/expresspackage.json (depends on@types/express-serve-static-core@^5.0.0) [2] npm version history showing both4.17.xand5.0.xlines for@types/express[3] Express official “Migrating to Express 5” guide
🏁 Script executed:
python - <<'PY' import json, pathlib, re def major(v: str): m = re.search(r'(\d+)', v or '') return int(m.group(1)) if m else None for p in pathlib.Path('e2e').rglob('package.json'): data = json.loads(p.read_text()) deps = data.get('dependencies', {}) dev = data.get('devDependencies', {}) if 'express' in deps and '@types/express' in dev: ex = deps['express'] ty = dev['@types/express'] status = "OK" if major(ex) == major(ty) else "MISMATCH" print(f"{p}: express={ex}, `@types/express`={ty} => {status}") PYRepository: TanStack/router
Length of output: 452
Align
expressand@types/expressmajor versions.Runtime
expressv4 is paired with@types/expressv5, which models Express 5 and pulls in incompatible type definitions. This causes type/API mismatches in strict TypeScript contexts. Fix by downgrading@types/expressto v4, or upgrading both to Express 5. The same mismatch exists across e2e fixtures.🔧 Suggested patch (if staying on Express 4)
"devDependencies": { "@playwright/test": "^1.50.1", "@tanstack/router-e2e-utils": "workspace:^", - "@types/express": "^5.0.3", + "@types/express": "^4.17.21", "@types/node": "^22.10.2",📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
"express": "^4.21.2", "react": "^19.0.0", "react-dom": "^19.0.0" }, "devDependencies": { "@playwright/test": "^1.50.1", "@tanstack/router-e2e-utils": "workspace:^", "@types/express": "^4.17.21", "@types/node": "^22.10.2",🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@e2e/react-start/split-base-and-basepath/package.json` around lines 18 - 26, The package.json shows a runtime dependency "express" at v4 while devDependencies use "@types/express" v5 causing type mismatches; update the dependency pair so their major versions match—either change "@types/express" to a v4 release (e.g., ^4.x) to match "express": "^4.21.2", or upgrade "express" to v5 and set "@types/express" to the corresponding v5; apply the same alignment to any other e2e fixture package.json files that list "express" and "@types/express".✅ Addressed in commit bec3134
@@ -0,0 +1,14 @@1+import { expect, test } from '@playwright/test'2+3+test.describe('split base and basepath', () => {4+ test('page renders at root /', async ({ page }) => {5+ await page.goto('/')6+ await expect(page.getByTestId('home-heading')).toHaveText('Welcome Home')7+ })8+9+ test('SSR HTML contains asset URLs prefixed with /_ui/', async ({10+ request,11+ }) => {12+ const response = await request.get('/')13+ const html = await response.text()14+⚠️ Potential issue | 🟡 Minor
Assert SSR response success before parsing HTML.
At Line 12, add an
ok()assertion so failures surface as request/setup errors instead of downstream regex/assert noise.🔧 Suggested patch
test('SSR HTML contains asset URLs prefixed with /_ui/', async ({ request, }) => { const response = await request.get('/') + expect(response.ok(), 'SSR GET / should return a successful response').toBeTruthy() const html = await response.text()📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const response = await request.get('/') expect(response.ok(), 'SSR GET / should return a successful response').toBeTruthy() const html = await response.text()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@e2e/react-start/split-base-and-basepath/tests/app.spec.ts` around lines 12 - 14, The test currently parses HTML from the fetch without first asserting the HTTP response succeeded; add an explicit success assertion immediately after `const response = await request.get('/')` (for example `ok(response.ok)` or `assert.strictEqual(response.status, 200)`) so request failures surface as a clear test/setup error before `const html = await response.text()` and downstream regex/assert noise; update the test near the `request.get('/')` call to perform this check.✅ Addressed in commit bec3134
@@ -389,3 +396,20 @@389396 getClientBundle: () => getBundle(VITE_ENVIRONMENT_NAMES.client),390397 getConfig,391398 }),399+ // When the vite base and router basepath are misaligned (e.g. base: '/_ui/', basepath: '/'),400+ // install a middleware that rewrites incoming request URLs to prepend the vite base prefix.401+ // This allows Vite's internal base middleware to accept the requests, then strips the prefix402+ // before passing to the SSR handler.403+ // Registered BEFORE devServerPlugin so this middleware is added to the Connect stack first,404+ // ensuring all subsequent middlewares (CSS, SSR, etc.) see the rewritten URL.405+ {406+ name: 'tanstack-start-core:dev-base-rewrite',407+ configureServer(server) {408+ if (!needsDevBaseRewrite) {409+ return410+ }411+ const base = resolvedStartConfig.viteAppBase412+ server.middlewares.use((req, _res, next) => {413+ if (req.url && !req.url.startsWith(base)) {414+ req.url = base.replace(/\/$/, '') + req.url415+ }⚠️ Potential issue | 🟡 Minor
Avoid double-prefixing URLs already at base root.
The current check misses base-root variants like
/_uiand/_ui?x=1(when base is/_ui/), so they get rewritten to/_ui/_ui.... Normalize comparisons with and without trailing slash before prefixing.Proposed fix
const base = resolvedStartConfig.viteAppBase + const baseNoTrailingSlash = base.replace(/\/$/, '') server.middlewares.use((req, _res, next) => { - if (req.url && !req.url.startsWith(base)) { - req.url = base.replace(/\/$/, '') + req.url + if ( + req.url && + req.url !== baseNoTrailingSlash && + !req.url.startsWith(`${baseNoTrailingSlash}/`) + ) { + req.url = `${baseNoTrailingSlash}${req.url.startsWith('/') ? '' : '/'}${req.url}` } next() })📝 Committable suggestion
‼️ IMPORTANT Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const base = resolvedStartConfig.viteAppBase const baseNoTrailingSlash = base.replace(/\/$/, '') server.middlewares.use((req, _res, next) => { if ( req.url && req.url !== baseNoTrailingSlash && !req.url.startsWith(`${baseNoTrailingSlash}/`) ) { req.url = `${baseNoTrailingSlash}${req.url.startsWith('/') ? '' : '/'}${req.url}` } next() })🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/start-plugin-core/src/plugin.ts` around lines 413 - 415, The rewrite logic that prefixes req.url with base can double-prefix when req.url already equals the base root with or without a trailing slash or query (e.g., "/_ui" or "/_ui?x=1"); update the check to normalize base (e.g., let normalizedBase = base.replace(/\/$/, '')) and only prefix when req.url does not already start with normalizedBase nor normalizedBase + '/' nor equal normalizedBase (and handle query strings implicitly), i.e., replace the current if (req.url && !req.url.startsWith(base)) { ... } with a comparison against the normalizedBase variants using the existing req.url and base symbols so URLs at the base root are not rewritten.✅ Addressed in commit bec3134
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 7cd49b6a17e597f3b9f63d2f0012e94c01b85f7e and bec31344ad0aa3a3602202bb305ad3fa6763ea8c.
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml📒 Files selected for processing (6)
e2e/react-start/custom-basepath/package.jsone2e/react-start/split-base-and-basepath/package.jsone2e/react-start/split-base-and-basepath/tests/app.spec.tse2e/solid-start/custom-basepath/package.jsone2e/vue-start/custom-basepath/package.jsonpackages/start-plugin-core/src/plugin.ts✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 Walkthrough
Walkthrough#
Adds a new e2e fixture (split-base-and-basepath) with router routes, tests, and Vite/Playwright configs; introduces dev-time URL-rewrite middleware in start-plugin-core to handle mismatched Vite base vs router basepath; removes a
defineconstant from an existing Vite config.Changes#
e2e/react-start/import-protection/vite.config.tsdefine.__IMPORT_PROTECTION_FIXTURE_ROOT__property from the exported Vite config.e2e/react-start/split-base-and-basepath/.gitignore,.../.prettierignore,.../package.json,.../playwright.config.ts,.../tsconfig.json,.../vite.config.tse2e/react-start/split-base-and-basepath/src/routeTree.gen.ts,.../src/router.tsx,.../src/routes/__root.tsx,.../src/routes/index.tsx,.../src/routes/about.tsx,.../src/styles/app.csse2e/react-start/split-base-and-basepath/prod-server.js,.../tests/app.spec.ts/_ui/, plus Playwright tests validating SSR asset prefixes and navigation.packages/start-plugin-core/src/plugin.tsneedsDevBaseRewriteflag and registers atanstack-start-core:dev-base-rewriteplugin that installs early Connect middleware to rewrite incoming request URLs by prefixing the Vite base in dev.e2e/*/custom-basepath/package.json(multiple)expressdependency from^4.21.2to^5.1.0in several e2e projects.Sequence Diagram#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs#
packages/start-plugin-core/src/plugin.tsthat add preview-server plugin registration and demonstrate similar plugin wiring.Suggested reviewers#
Poem#
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (2 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.