Replies: 1 comment 3 replies
-
@levipadre We recently enabled nonces for a client of ours and had to work with the team implementing Google Tag Manager to make it "nonce aware". This article may be of help to you: https://developers.google.com/tag-platform/security/guides/csp |
Beta Was this translation helpful? Give feedback.
3 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.
-
Summary
To Reproduce
1, install
npx create-next-app --example with-strict-csp with-strict-csp-app
2, install
npm install @next/third-parties
3, add:
4,change GTM code to a working one
5, add googletagmanager site to script-src:
script-src 'self' 'nonce-${nonce}' 'strict-dynamic' *.googletagmanager.com;
This would make it work with normal Script
Current behavior
Error message:
Refused to load the script 'https://www.googletagmanager.com/gtm.js?id=GTM-XXXXXXX' because it violates the following Content Security Policy directive: "script-src 'self' 'nonce-ZGFiZDVjOWMtNDZmZS00MmVhLTk3YmUtNGNhNGIzYzhiZDhm' 'strict-dynamic' *.googletagmanager.com". Note that 'strict-dynamic' is present, so host-based allowlisting is disabled. Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.
and:

Additional information
Example
Sorry, due to exposing GTM code I can't provide link
Beta Was this translation helpful? Give feedback.
All reactions