Start: prerender forces trailing slashes, causing unnecessary redirects with trailingSlash: "never"
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
- #8916 de @okxint — cerrado sin fusionar
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- node.js, react, typescript, vite
- Área
- backend, performance
Línea de trabajo
Start with @tanstack/start-plugin-core/src/prerender.ts, where the issue says the preview fetch URL is built using withTrailingSlash and withBase; trace how the trailing slash policy and base path reach that call. Use the linked reproducer’s npm ci and npm run build, then inspect its [preview-request] output. Done when explicit slashless paths with trailingSlash: 'never' are requested without the extra 307 redirect.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Which project does this relate to?
Start
Describe the bug
When the router uses trailingSlash: 'never', prerendering still appends a trailing
slash to each requested page URL. The router then returns a 307 redirect to the
slashless URL, and prerender follows it. This adds an unnecessary request for every
non-root page.
This happens with an explicit list of unique, slashless paths, with both
autoStaticPathsDiscovery and crawlLinks disabled. It reproduces with the default
Node preview server, without Cloudflare or any other adapter.
Complete minimal reproducer
https://github.com/R4ULtv/tanstack-start-prerender-trailing-slash
Steps to reproduce
- Clone the reproduction repository.
- Run
npm ci. - Run
npm run build. - Inspect the
[preview-request]lines in the output.
The reproduction has one dynamic route (/page/$id) and three explicit paths:
/page/1, /page/2, and /page/3. All input paths are slashless.
For each path the output shows:
[prerender] Crawling: /page/1
[preview-request] GET /page/1/ -> 307 Location: /page/1
[preview-request] GET /page/1 -> 200
The build succeeds, but each page requires two requests. The reproduction's Vite
plugin only logs the preview requests and response status/Location header; it does
not modify them. Setting PAGE_COUNT to 1 is sufficient to reproduce the issue.
Expected behavior
With trailingSlash: 'never', prerender should request slashless URLs directly,
avoiding the redirect for each page. URL normalization should account for the
configured trailing-slash policy and base path.
Platform
@tanstack/react-start: 1.169.4@tanstack/react-router: 1.170.46@tanstack/start-plugin-core(transitive): 1.171.55- React / React DOM: 19.3.1
- Vite: 8.3.5
- Node.js: 24.22.2
- OS: macOS (Apple Silicon)
- Adapter: default Node preview server
Additional context
In @tanstack/start-plugin-core/src/prerender.ts, the URL passed to fetch is
constructed with:
withTrailingSlash(withBase(page.path, routerBasePath))
This forces the slash even though the provided page path is already canonical.
The reproduction also contains an optional npm run benchmark that measures
increasing page counts, with four alternating-order runs per variant. It compares
current behavior with a preview-only rewrite that avoids the redirect, checks
request counts and generated output, and produces a self-contained HTML report
with the raw measurements. These are synthetic local Node results at concurrency
1; the percentage improvement is workload-specific and excludes deployment.
Recorded benchmark artifacts:
- Self-contained HTML report
- Raw measurements and verification metadata (JSON)
- Individual measured runs (CSV)
I mentioned this separately in #8483, which primarily concerns CPU parallelism.
This report isolates the redirect behavior independently of concurrency.
Related: #6978 / #7070 address duplicate discovered paths. This report concerns
additional HTTP requests for explicit, unique paths with discovery/crawling
disabled, so normalizing discovered paths alone would not resolve it.
Prepared with AI assistance. The reproduction and benchmark builds were executed and verified locally.
- Lenguaje dominante
- TypeScript
- Estrellas
- 15.3k
- Forks
- 1.9k
- Merge medio
- 1 d 5 h
- PR fusionados (30 d)
- 46
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/router
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')Posiblemente ocupada @hassanabrar202 la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)Posiblemente ocupada @Sheraff la tomó hace 27 días. Abiertopackage: router-generator performance
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiersPosiblemente ocupada @Sheraff la tomó hace 27 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
docs(router): clarify static title fallback in SPA modePosiblemente ocupada @Rohan-Dedhia la tomó hace 17 días. Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/router
Issues similares
-
[BUG]: Shared links drop the configured basePath on GitHub PagesPosiblemente ocupada @anshulchikhale30-p la tomó hoy. Abiertobug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Add: GTrekkerAbiertocheck:passed streams:add
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Koenkk/zigbee-herdsman-converters#13900 ·
Los mantenedores suelen responder en 1 día
-
area: ui Bug Payload OSS
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
payloadcms/payload#19839 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
jeanibarz/knowledge-base-mcp-server#1291 ·
Los mantenedores suelen responder en 1 día