fix(colors): remove inline script in Vue SPA mode for strict CSP#6577
fix(colors): remove inline script in Vue SPA mode for strict CSP#6577ReCoN-96 wants to merge 1 commit into
Conversation
Replace the temporary style cleanup script with a dom:rendered hook to comply with script-src 'self' without unsafe-inline.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR refactors the Nuxt UI colors plugin to eliminate Content Security Policy violations in browser extensions. The change replaces an inline script-based removal mechanism with a hook-based approach. The Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
commit: |
Replace the temporary style cleanup script with a dom:rendered hook to comply with script-src 'self' without unsafe-inline.
Summary
<script>injected by thecolorsplugin in Vue SPA mode (@nuxt/ui/vite+@nuxt/ui/vue-plugin), which violated strict CSP policies (script-src 'self'withoutunsafe-inline)<style data-nuxt-ui-colors>via Unhead'sdom:renderedhook insteadinjectHeadfrom the Vue SPA stub so the plugin can access the head instanceLinked issues
Resolves #4976
Related to #3394 (CSP / inline styles) but does not address
style-srcnonce support.Type of change
Test plan
pnpm run dev:vueand verifystyle#nuxt-ui-colorsis present in<head>[data-nuxt-ui-colors]is removed after page loadscript-src 'self') in the Vue playground and confirm no CSP violation in the consoleserverRenderedis true)