Skip to content
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

Nonce not added as attribute #413

Closed
joerees opened this issue Feb 28, 2024 · 3 comments
Closed

Nonce not added as attribute #413

joerees opened this issue Feb 28, 2024 · 3 comments

Comments

@joerees
Copy link

joerees commented Feb 28, 2024

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()
    }
  }
})`
@Shinigami92
Copy link
Contributor

Maybe you need to use this: #209 (comment)

@joerees
Copy link
Author

joerees commented Feb 28, 2024

Tried this already but makes no difference, nonce does not get applied correctly

@dariasamo
Copy link

Same here, nonce is not applied. Tried with both @gtm-support/vue-gtm and @zadigetvoltaire/nuxt-gtm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants