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 Headers cause issues #2284

Open
1 task done
jay-linumlabs opened this issue Jan 7, 2025 · 1 comment
Open
1 task done

[bug] CSP Headers cause issues #2284

jay-linumlabs opened this issue Jan 7, 2025 · 1 comment

Comments

@jay-linumlabs
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

RainbowKit Version

2.1.2

wagmi Version

2.13.5

Current Behavior

Currently we get the following error

Refused to apply inline style because it violates the following Content Security Policy directive: "style-src-elem 'self'

It boils down to the Rainbow Kit injecting styles into the page
Screenshot 2025-01-07 at 19 00 05

There is currently no way to set the nonce on the style tag forcing us to use 'unsafe-inline' which is not ideal.

Expected Behavior

being able to pass down the nonce through the <RainbowKitProvider /> so that any and all script and style tags include the nonce

<RainbowKitProvider nonce={nonce}>
....
<RainbowKitProvider />

the outcome should look like this:

Screenshot 2025-01-07 at 19 11 52

Steps To Reproduce

Set your CSP headers for your application i.e.

const cspHeader = [
    `default-src 'self';`,
    `script-src 'self' 'nonce-${nonce}';`,
    `style-src 'self' https://fonts.googleapis.com https://fonts.gstatic.com;`,
    `style-src-elem 'self'  https://fonts.googleapis.com https://fonts.gstatic.com;`,
    `font-src 'self' https://fonts.googleapis.com https://fonts.gstatic.com;`,
    `frame-src 'self';`,
    `object-src 'none';`,
  ].join(" ");
  
responseHeaders.set("Content-Security-Policy", cspHeader);

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

No response

Anything else?

There was this ticket #1256 about the same thing, but no resolution and it was closed.

Copy link

linear bot commented Jan 7, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant