Skip to content
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

[Bug]: CSP inline style error even when noonce is provided #303

Closed
ryparker opened this issue Jun 29, 2024 · 1 comment
Closed

[Bug]: CSP inline style error even when noonce is provided #303

ryparker opened this issue Jun 29, 2024 · 1 comment
Labels
bug Something isn't working triage

Comments

@ryparker
Copy link

ryparker commented Jun 29, 2024

What happened?

When wrapping layout with the ThemeProvider and a noonce provided, and a strict CSP style-src, then I receive the following error in console:

layout-5770ccc27b841829.js:1 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'nonce-YjZlNzFjOTItYjNlYy00MTBhLWJjODAtZDE3N2VlOWY2Y2Yz'". Either the 'unsafe-inline' keyword, a hash ('sha256-GNF74DLkXb0fH3ILHgILFjk1ozCF3SNXQ5mQb7WLu/Y='), or a nonce ('nonce-...') is required to enable inline execution.

The error references the following code:

, f = ()=>{
            let e = document.createElement("style");
            return e.appendChild(document.createTextNode("*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),
            document.head.appendChild(e),  <--- Error line
            ()=>{
                window.getComputedStyle(document.body),
                setTimeout(()=>{
                    document.head.removeChild(e)
                }
                , 1)
            }
        }
          , h = e=>(e || (e = window.matchMedia(a)),
        e.matches ? "dark" : "light")

document.head.appendChild(e), is the referenced error line.

Tested it on a production build of a nextjs (v14.2.4 w/ app dir) app, error logs twice in console (duplicates). Page only renders the provider, nothing else.

Browser: Brave

Version

0.3.0

What browsers are you seeing the problem on?

Chrome (brave)

@ryparker ryparker added bug Something isn't working triage labels Jun 29, 2024
@BaDo2001
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage
Projects
None yet
Development

No branches or pull requests

2 participants