-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: nonce support #5287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: nonce support #5287
Conversation
WalkthroughAdds optional nonce support across React and Solid router rendering paths. Propagates router.options.ssr?.nonce into SSR render options and through HeadContent/Scripts into Asset and Script elements, applying nonce to link, style, and script tags. Public Asset signature updated to accept nonce. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant App
participant Router
participant HeadContent
participant Scripts
participant Asset
participant Script
App->>Router: initialize with options.ssr?.nonce
Router->>HeadContent: render()
HeadContent->>Asset: render(tag, attrs, children, nonce)
Router->>Scripts: render()
Scripts->>Asset: render(tag=script, attrs, children, nonce)
Asset->>Script: render(nonce, attrs, children)
Script-->>Asset: <script nonce=...>
Asset-->>HeadContent: <link/style/script nonce=...>
Asset-->>Scripts: <script nonce=...>
sequenceDiagram
autonumber
participant Server
participant Router
participant ReactSSR as ReactDOMServer
participant SolidSSR as Solid SSR
Server->>Router: renderRouterToStream()/renderRouterToString()
alt React path
Router->>ReactSSR: render(..., { nonce: router.options.ssr?.nonce })
ReactSSR-->>Server: HTML/stream with nonce-aware tags
else Solid path
Router->>SolidSSR: render(..., { nonce: router.options.ssr?.nonce })
SolidSSR-->>Server: HTML/stream with nonce-aware tags
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (6)
🧰 Additional context used📓 Path-based instructions (2)**/*.{ts,tsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
packages/{react-router,solid-router}/**📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (1)📚 Learning: 2025-09-23T17:36:12.598Z
Applied to files:
🧬 Code graph analysis (2)packages/react-router/src/HeadContent.tsx (1)
packages/react-router/src/Scripts.tsx (1)
🪛 ast-grep (0.39.5)packages/react-router/src/Asset.tsx[warning] 31-31: Usage of dangerouslySetInnerHTML detected. This bypasses React's built-in XSS protection. Always sanitize HTML content using libraries like DOMPurify before injecting it into the DOM to prevent XSS attacks. (react-unsafe-html-injection) 🪛 Biome (2.1.2)packages/react-router/src/Asset.tsx[error] 32-32: Avoid passing content using the dangerouslySetInnerHTML prop. Setting content using code can expose users to cross-site scripting (XSS) attacks (lint/security/noDangerouslySetInnerHtml) ⏰ 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 (5)
Comment |
View your CI Pipeline Execution ↗ for commit cb01ecd
☁️ Nx Cloud last updated this comment at |
More templates
@tanstack/arktype-adapter
@tanstack/directive-functions-plugin
@tanstack/eslint-plugin-router
@tanstack/history
@tanstack/nitro-v2-vite-plugin
@tanstack/react-router
@tanstack/react-router-devtools
@tanstack/react-router-ssr-query
@tanstack/react-start
@tanstack/react-start-client
@tanstack/react-start-server
@tanstack/router-cli
@tanstack/router-core
@tanstack/router-devtools
@tanstack/router-devtools-core
@tanstack/router-generator
@tanstack/router-plugin
@tanstack/router-ssr-query-core
@tanstack/router-utils
@tanstack/router-vite-plugin
@tanstack/server-functions-plugin
@tanstack/solid-router
@tanstack/solid-router-devtools
@tanstack/solid-start
@tanstack/solid-start-client
@tanstack/solid-start-server
@tanstack/start-client-core
@tanstack/start-plugin-core
@tanstack/start-server-core
@tanstack/start-static-server-functions
@tanstack/start-storage-context
@tanstack/valibot-adapter
@tanstack/virtual-file-routes
@tanstack/zod-adapter
commit: |
Summary by CodeRabbit