Skip to content

Missing script property nonce聽#111

Open

Description

@w1ckedmellow

Hi Didomi team 馃憢
We're currently integrating the Didomi React SDK into a project that enforces a strict Content Security Policy (CSP), which requires all inline scripts to include a nonce attribute. However, we noticed that the SDK does not provide a way to set a nonce on the injected <script> tags, which causes CSP violations and blocks the Didomi scripts from executing.
Expected behavior:
There should be a way to pass a nonce value (e.g., via a prop or config option) so that the SDK can include it in the <script> tags it injects.
Actual behavior:
No nonce attribute is added to the injected scripts, and CSP blocks them.
Suggested solution:
Add support for a nonce prop in the React component or configuration object, which would be applied to all dynamically injected <script> elements.
Environment:

Package: @didomi/react
Framework: React
CSP: strict mode with script-src 'nonce-xyz'

Activity

  1. felipe-saez commented on Nov 7, 2025

    @felipe-saez

    Hi,

    Thanks for bringing this up and for the detailed context. We鈥檙e currently looking into the issue and evaluating how to best support CSP nonces in our SDK.

    We鈥檒l keep you posted as soon as we have any updates on this.

    Kind regards,

    Felipe

  2. honzalo commented on Nov 26, 2025

    @honzalo
    Contributor

    We鈥檝e added support for a custom nonce. You can now dynamically add the following code before the SDK is initialized:

    const didomiConfig = {
      app: {
        nonce: nonceValue,
      },
    };
    
    <DidomiSDK
      config={didomiConfig}
    [...]
    

    The SDK will then automatically add the nonce attribute to the injected styles/script.

    Let me know if you have any questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions