ssr.nonce set after the router is created no longer reaches the hydration scripts (regression in 1.171.31)
Los mantenedores suelen responder en 1 día
@aliassar ya está trabajando en esto.
Desde el 3/11/2026.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- react, typescript
- Área
- backend, full-stack
Línea de trabajo
Start in packages/router-core/src/ssr/ssr-server.ts at the attachRouterServerSsrUtils code linked in the issue, and trace how the hydration state and inline scripts read router.options.ssr?.nonce. Compare that with the earlier per-script reads described in the issue. Done when the hydration and trailing inline scripts use a nonce set in the createStartHandler callback, with the regression reproducer confirming hydration succeeds under nonce-based CSP.
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
Since router-core 1.171.31 (#8204), attachRouterServerSsrUtils reads router.options.ssr?.nonce once, when it creates the request's hydration state:
https://github.com/TanStack/router/blob/94d6d8e4/packages/router-core/src/ssr/ssr-server.ts#L406
Before #8204, injectScript and the $tsr barrier script read it each time they wrote a script, so an app could set the nonce after the router was created, for example in the createStartHandler callback. Now the hydration <script data-tsr-stream-part> and the trailing inline <script> render without a nonce, a nonce-based CSP blocks them, and hydration fails with TypeError: Cannot set properties of undefined (setting 't'). The module script still gets the nonce, and nothing fails on the server.
// src/server.ts
const startFetch = createStartHandler((ctx) => {
const nonce = crypto.randomUUID()
ctx.router.options.ssr = { ...ctx.router.options.ssr, nonce }
// ...set `Content-Security-Policy: script-src 'nonce-${nonce}' 'strict-dynamic'`
return defaultStreamHandler(ctx)
})
Complete minimal reproducer
https://github.com/TrevorBurnham/tanstack-nonce-repro
Steps to Reproduce the Bug
- Set
ssr.noncein thecreateStartHandlercallback as above, and send a CSP withscript-src 'nonce-<n>'. - Build and serve with router-core 1.171.30 (react-start 1.168.54). Every inline script has the nonce and the page hydrates.
- Upgrade to router-core 1.171.31 (react-start 1.168.55). The two inline scripts lose the nonce, the console reports two CSP violations and the TypeError, and the page content disappears. Still present in react-start 1.169.3 (router-core 1.171.38).
Setting the nonce in getRouter() (passing it in as request context) works around it.
Expected behavior
Either the hydration scripts pick up a nonce set any time before rendering, as before, or the docs say ssr.nonce must be set when the router is created, and a dev-mode warning catches a nonce that changes after the SSR utilities are attached.
Platform
- Router / Start Version: router-core 1.171.31 through 1.171.38 (last working: 1.171.30)
- OS: macOS, Linux (AWS Lambda)
- Browser: Chrome
- Bundler: vite 8.2.1
- 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