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

Access to fetch at 'https://www.google-analytics.com/analytics.js' from origin #433

Open
dbelouslv opened this issue Jul 31, 2024 · 0 comments

Comments

@dbelouslv
Copy link

dbelouslv commented Jul 31, 2024

nuxt.config.ts:

ssr: true,

modules: ['@nuxtjs/partytown']

partytown: {
    forward: ['dataLayer.push'],
    debug: false
},

app: {
    head: {
        title: '',
        meta: [
            { charset: 'utf-8' },
            { name: 'viewport', content: 'width=device-width,initial-scale=1.0' },
            { 'http-equiv': 'X-UA-Compatible', content: 'IE=edge' }
        ],
        link: [
            { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
        ],
        script: [
            {
                type: 'text/partytown',
                innerHTML: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-XXXXXX');`
            }
        ]
    }
}

I got this error:

Access to fetch at 'https://www.google-analytics.com/analytics.js' from origin 'https://stage.mysite.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

By the way with gtm script everything is ok, but with analytics..

image

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

1 participant