fix(query-devtools): set window.__nonce__ in setupStyleSheet#10736
fix(query-devtools): set window.__nonce__ in setupStyleSheet#10736842u wants to merge 4 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR improves CSP nonce handling in ChangesCSP Nonce Propagation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎯 Changes
Problem
When passing
styleNonceto<ReactQueryDevtools>, user still receive CSP violations for thedevtools
<style>element even though the nonce prop is correctly provided.Root cause
The devtools use goober for CSS-in-JS. Goober uses
window.__nonce__asits CSP hook, reading it every time it creates or accesses its style element. Since
setupStyleSheetnever set it, goober always overwrote the nonce with
undefined, causing the CSP violation.Solution
Set
window.__nonce__insidesetupStyleSheetbefore the element is created or inserted:✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
Bug Fixes
Tests