There’s nothing in the provided sources that directly explains server middleware not running on Cloudflare Workers for Nuxt 4.2.1, so I can’t state the exact cause with certainty.
From the available context, we do know:
- In Nuxt 4.2, the dev/prod server architecture changed so that all requests go through Nitro first, and Vite (or other layers) are only reached if Nitro passes them on. [vite proxy change]
- On Cloudflare Workers, there are some platform‑specific quirks around request handling (e.g. DELETE +
routeRules.proxy causing hangs due to headers / body expectations), which required workarounds using custom server routes instead of routeRules. [CF DELETE issue]
However, none of the sources mention:
- Server middleware being skipped or disabled on Cloudflare Workers.
- Any special configuration needed to enable
server/middleware/*.global.ts on that platform.
- A known bug in 4.2.1 where server middleware doesn’t run on Workers.
Given that:
- Your middleware is in the correct directory (
server/middleware/…global.ts), which is how Nuxt server middleware is normally registered.
- It works locally, which suggests the file name and logic are valid.
But I don’t have any source that confirms:
- Whether Cloudflare Workers + Nuxt 4.2.1 has a regression specifically affecting server middleware.
- Any required Cloudflare‑specific configuration to ensure those handlers run.
Because of that, I can’t reliably tell you why it’s not executing on Cloudflare Workers or propose a documented fix based on these sources alone.
If you can, I’d recommend: