ssr.nonce set after the router is created no longer reaches the hydration scripts (regression in 1.171.31)
Maintainer thường phản hồi trong vòng 1 ngày
@aliassar đang làm issue này rồi.
Từ ngày 3/11/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, typescript
- Lĩnh vực
- backend, full-stack
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- TypeScript
- Star
- 15.3k
- Fork
- 1.9k
- Merge trung bình
- 1 ngày 5 giờ
- Pull request đã merge (30 ngày)
- 46
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/router
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')Có thể đã có người làm @hassanabrar202 đã nhận 8 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)Có thể đã có người làm @Sheraff đã nhận 27 ngày trước. Đang mởpackage: router-generator performance
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiersCó thể đã có người làm @Sheraff đã nhận 27 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
docs(router): clarify static title fallback in SPA modeCó thể đã có người làm @Rohan-Dedhia đã nhận 17 ngày trước. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của TanStack/router
Issue tương tự
-
[BUG]: Shared links drop the configured basePath on GitHub PagesCó thể đã có người làm @anshulchikhale30-p đã nhận hôm nay. Đang mởbug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: GTrekkerĐang mởcheck:passed streams:add
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Koenkk/zigbee-herdsman-converters#13900 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area: ui Bug Payload OSS
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
payloadcms/payload#19839 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
jeanibarz/knowledge-base-mcp-server#1291 ·
Maintainer thường phản hồi trong vòng 1 ngày