Skip to content

Cloudflare Web Analytics in SSR:false #875

Description

@RaphaelDDL

📚 What are you trying to do?

Set Cloudflare Web Analytics in SSR:false nuxt.

🔍 What have you tried?

I followed https://scripts.nuxt.com/scripts/cloudflare-web-analytics and added to my nuxt.config:

 scripts: {
registry: {
// NUXT_PUBLIC_SCRIPTS_CLOUDFLARE_WEB_ANALYTICS_TOKEN
cloudflareWebAnalytics: { trigger: 'onNuxtReady', spa: true },
}
},

And I added NUXT_PUBLIC_SCRIPTS_CLOUDFLARE_WEB_ANALYTICS_TOKEN as an env var.

I am using ssr:false and with nuxi generate to deploy in cloudflare workers. But when deploying it, it's trying to hit <domain>/_scripts/p/cloudflareinsights.com/cdn-cgi/rum which is giving 405, and I believe is wrong.

Shouldn't nuxt's ssr:false (and/or script's spa:true) make it just attach the script like the commented sample in https://github.com/nuxt/scripts/blob/main/packages/script/src/runtime/registry/cloudflare-web-analytics.ts since has no server or route?

In the meantime, I'm adding it directly and is working:

 app: {
head: {
script: [
{
src: 'https://static.cloudflareinsights.com/beacon.min.js',
'data-cf-beacon': '{"token": "MYTOKEN"}',
defer: true,
},
],

Thanks for any help.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions