Skip to content

Google Tag Manager 400 Error #441

Open
@JonathanXDR

Description

@JonathanXDR

🐛 The bug

When running or building a Nuxt project that uses the Nuxt Scripts module, the build fails with a 400 Bad Request error originating from a request to https://www.googletagmanager.com/gtm.js.

🛠️ To reproduce

https://stackblitz.com/edit/nuxt-starter-qsvb2xmv?file=nuxt.config.ts

🌈 Expected behavior

The build should succeed without errors, even when GTM is integrated.

ℹ️ Additional context

System

Logs:

jonathan@MacBook-Pro-von-Jonathan Application-Website-Frontend % nr build
$ nuxt build
Nuxt 3.16.1 with Nitro 2.11.8                                                                                                                                                   nuxi  16:38:06
ℹ Using Tailwind CSS from ~/assets/css/tailwind.css                                                                                                                 nuxt:tailwindcss 16:38:07
ℹ Nuxt Icon server bundle mode is set to local                                                                                                                                       16:38:07
✔ Nuxt Icon discovered local-installed 4 collections: fa6-brands, fa6-solid, logos, simple-icons                                                                                     16:38:08
✔ Nuxt Icon loaded local collection simple-icons-extended with 3 icons                                                                                                               16:38:08
✔ Nuxt Icon loaded local collection sf-symbols-small with 6404 icons                                                                                                                 16:38:09
✔ Nuxt Icon loaded local collection sf-symbols-medium with 6404 icons                                                                                                                16:38:09
✔ Nuxt Icon loaded local collection sf-symbols-large with 6404 icons                                                                                                                 16:38:09
ℹ Running with compatibility version 4                                                                                                                                          nuxt 16:38:09
ℹ Building for Nitro preset: node-server                                                                                                                                       nuxi  16:38:09
ℹ Building client...                                                                                                                                                                 16:38:10
ℹ vite v6.2.4 building for production...                                                                                                                                             16:38:10
ℹ ✓ 685 modules transformed.                                                                                                                                                         16:38:14

 ERROR  ✗ Build failed in 6.08s                                                                                                                                                       16:38:16


 ERROR  Nuxt Build Error: [nuxt:scripts:bundler-transformer] [GET] "https://www.googletagmanager.com/gtm.js": 400 Bad Request                                                   nuxi  16:38:16
file: virtual:nuxt:%2FUsers%2Fjonathan%2FDeveloper%2FGit%2FGitHub%2FApplication-Website-Frontend%2Fnode_modules%2F.cache%2Fnuxt%2F.nuxt%2Fmodules%2F%40nuxt-scripts%2Fplugin.mjs

    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async downloadScript (node_modules/@nuxt/scripts/dist/module.mjs:186:11)
    at async Object.enter (node_modules/@nuxt/scripts/dist/module.mjs:325:23)
    at async AsyncWalker.visit (node_modules/estree-walker/src/async.js:65:5)
    at async AsyncWalker.visit (node_modules/estree-walker/src/async.js:107:7)
    at async AsyncWalker.visit (node_modules/estree-walker/src/async.js:100:15)
    at async AsyncWalker.visit (node_modules/estree-walker/src/async.js:100:15)
    at async AsyncWalker.visit (node_modules/estree-walker/src/async.js:107:7)
    at async AsyncWalker.visit (node_modules/estree-walker/src/async.js:107:7)
    at async AsyncWalker.visit (node_modules/estree-walker/src/async.js:100:15)

error: script "build" exited with code 1
jonathan@MacBook-Pro-von-Jonathan Application-Website-Frontend % 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions