-
Notifications
You must be signed in to change notification settings - Fork 140
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
Violation of Content Security Policy directive script-src that disables inline scripts #41
Comments
I am facing the same issue, any pointers? |
What I found is that GTM is actually the issue. They force you to add unsafe-inline for scripts, so I stopped using GTM. I just use regular analytics instead. Google's advisory on this topic: https://developers.google.com/tag-manager/web/csp |
Have tried out this pull request #46 doesnt seem to help me. |
@lovelstn did you set up nonces correctly? In addition you still need required CSP rules to be set up (see https://developers.google.com/tag-manager/web/csp), but in the end it works for where I use it. |
@webjunkie I tried the same as mentioned in that article, but it still errors. Would it be possible to share an example code, describing how you set it. Thank you |
same problem here |
Same here. I've also tried this PR: #46 and it does seem to solve the issue. Any chance that PR will merge soon? |
When the PR: #46 is going to be merged? any time soon? |
Following thread resolved this issue: https://stackoverflow.com/questions/65100704/gtm-not-propagating-nonce-to-custom-html-tags |
…ements are allowed to run on CSP enabled sites. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/script-src#Unsafe_inline_script Fixes [alinemorelli#41](alinemorelli#41) constibution by [@webjunkie](https://github.com/webjunkie)
TagManager.js:59 appears to fail CSP directive that prevents inline scripts.
react-gtm/dist/TagManager.js
Line 59 in 52f2328
My Content-Security-Policy directive is:
script-src 'self' https://*.googletagmanager.com https://*.googleapis.com https://*.google.com https://*.google-analytics.com https://*.gstatic.com;
Google's console responds with:
Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' https://*.googletagmanager.com https://*.googleapis.com https://*.google.com https://*.google-analytics.com https://*.gstatic.com". Either the 'unsafe-inline' keyword, a hash ('sha256-AmDiJyvKvr94dB5Fpw4fKR7GDBqrf2xZhnMaV3YAPrA='), or a nonce ('nonce-...') is required to enable inline execution.
I definitely can't allow 'unsafe-inline' in my app. Any ideas?
The text was updated successfully, but these errors were encountered: