Replies: 1 comment
|
The better way is to put the CSS on the .css file 😄 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi, I'm working on a new web app with a strict CSP required. On lines 513, 532 of tarteaucitron.js there are some dynamic CSS Rules added that trigger errors on browser (they have
TODOcomments in order to add them to the CSS file).I've managed to solve it by adding this on backend PHP code:
"style-src-elem 'nonce-" . $nonce . "' 'self' 'sha256-fsYXbbdxpSYs34GT6F5tr23KpZf1q65FBknssNyLnLo=' ;"This
hashcorresponds to line 521:document.getElementsByTagName('head')[0].appendChild(customThemeMiddle);, or the CSS that it appends (declared ascssRuleMiddleon line 513).I've only tried this solution with script 'middle' theme, as it's the one I use.
Edit: I forgot to mention that I've also added
integrity="sha256-45jaHcWwlrBC9cPaZo6INU6AgU8m7O6fO0RDY6VFomg="on HTML<script>tag, like this:<script nonce="…" src="scripts/tarteaucitron/tarteaucitron.js" integrity="sha256-45jaHcWwlrBC9cPaZo6INU6AgU8m7O6fO0RDY6VFomg=" crossorigin="anonymous"></script>I hope this hack will help some of you out there who need to work with strict CSP rules, or maybe I'm wrong and there's a simpler, or better, way to solve it :)
BTW, I don't know if this is the right place to comment this issue.
Salut à toi Amauri et merci pour ton superb travail.
All reactions