Support the ongoing development of Laravel.io →
Laravel Security Encryption

While implementing the Spatie CSP I'm getting following error in the console.

302 Refused to apply inline style because it violates the following Content Security Policy directive: "style-src 'self' 'nonce-SgUZxdNxqed9LtD9Z4xvx9e8fZllmR10' fonts.googleapis.com cdn.jsdelivr.net cdn.datatables.net cdnjs.cloudflare.com rawgit.com 'unsafe-inline'". Note that 'unsafe-inline' is ignored if either a hash or nonce value is present in the source list.

Pointer.js:29 Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'nonce-SgUZxdNxqed9LtD9Z4xvx9e8fZllmR10' code.jquery.com cdn.jsdelivr.net cdn.datatables.net cdnjs.cloudflare.com rawgit.com jqueryvalidation.org 'unsafe-inline'".

This is my policy

` // Add allowed domains for styles $this->addDirective(Directive::STYLE, 'fonts.googleapis.com'); $this->addDirective(Directive::STYLE, 'cdn.jsdelivr.net'); $this->addDirective(Directive::STYLE, 'cdn.datatables.net'); $this->addDirective(Directive::STYLE, 'cdnjs.cloudflare.com'); $this->addDirective(Directive::STYLE, 'rawgit.com');

    // Add allowed domains for fonts
    $this->addDirective(Directive::FONT, 'fonts.gstatic.com');
    $this->addDirective(Directive::FONT, 'cdnjs.cloudflare.com');
    $this->addDirective(Directive::FONT, 'localhost');
    
    // Add allowed domains for scripts
    $this->addDirective(Directive::SCRIPT, 'code.jquery.com');
    $this->addDirective(Directive::SCRIPT, 'cdn.jsdelivr.net');
    $this->addDirective(Directive::SCRIPT, 'cdn.datatables.net');
    $this->addDirective(Directive::SCRIPT, 'cdnjs.cloudflare.com');
    $this->addDirective(Directive::SCRIPT, 'rawgit.com');
    $this->addDirective(Directive::SCRIPT, 'jqueryvalidation.org'); 
    $this->addDirective(Directive::STYLE, 'unsafe-inline');
    $this->addDirective(Directive::SCRIPT, 'unsafe-inline');

` Can anyone help me to resolve this issue ?

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Arunraj S arunrajs Joined 24 Feb 2024

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.