For security concern, we replaced "unsafe-inline" with nonce for script-src in CSP config for the script in index.html.
script-src 'self' 'nonce-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
Embedded js in index.html:
<script nonce="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
}
But there are still some errors in console:
And checking details, it seems the tags.js injecting script to the body element and is forbidden:
To eliminate these errors, we have to use unsafe-inline for script-src-elem, but it is still not safe enough.
Wonder if there is a better solution to this issue? I tried search but found all about using nonce for injecting Google-Analytics code to index.html itself.
Thanks!


