vue-gtm
vue-gtm copied to clipboard
Nonce not added as attribute
This plugin does not apply the nonce attribute to the gtm script tag. when inspecting the script element in chrome I can see no nonce value added to the attributes list, however it is there as a property.
This is the following error breaking our CSP.
The source list for the Content Security Policy directive 'script-src' contains an invalid source: ''nonce-{{nonce}}''. It will be ignored.
Here is my implementation, is there a work around or fix ?
`import { createGtm, useGtm } from '@gtm-support/vue-gtm'
import analyticsFactory from '~/services/analytics/analyticsFactory'
export default defineNuxtPlugin((nuxtApp) => {
const config = useRuntimeConfig()
const nonce = useNonce()
nuxtApp.vueApp.use(
createGtm({
id: 'XXXXXXXXXXX',
enabled: true,
nonce
})
)
return {
provide: {
gtm: useGtm(),
dataLayer: analyticsFactory()
}
}
})`
Maybe you need to use this: https://github.com/gtm-support/vue-gtm/issues/209#issuecomment-1732417673
Tried this already but makes no difference, nonce does not get applied correctly
Same here, nonce is not applied. Tried with both @gtm-support/vue-gtm
and @zadigetvoltaire/nuxt-gtm
.