Skip to content

fix: inline axios so cloudflare_module Worker deploy succeeds#126

Merged
TheMeinerLP merged 1 commit into
mainfrom
claude/fix-axios-worker-bundle
May 15, 2026
Merged

fix: inline axios so cloudflare_module Worker deploy succeeds#126
TheMeinerLP merged 1 commit into
mainfrom
claude/fix-axios-worker-bundle

Conversation

@TheMeinerLP
Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #125. The cloudflare_module preset is now on main, but the Worker deploy fails:

✘ [ERROR] Could not resolve "axios"
  .output/server/chunks/build/server.mjs: ...if(!cw){const e=require("axios");...

posthog-node (used server-side by nuxt-posthog) does a lazy require("axios"). Under the old cloudflare_pages preset Nitro bundled everything itself; under cloudflare_module Nitro leaves axios as an external require that wrangler's esbuild cannot resolve in .output (no node_modules there).

Change

  • Add axios to nitro.externals.inline so Nitro bundles it into the server output, reproducing the prior bundling behaviour. Runtime behaviour is unchanged (the same code already ran in the previous Pages Worker).

One-line change in nuxt.config.ts.

Test plan

  • Cloudflare build + wrangler deploy completes without the Could not resolve "axios" error
  • Site renders and PostHog server-side events still work

https://claude.ai/code/session_012YWscdohmouZHhZ7otKnqh


Generated by Claude Code

posthog-node lazily requires axios; with the cloudflare_module preset
Nitro leaves it as an external require that wrangler's esbuild cannot
resolve in .output, failing the deploy. Inlining axios via Nitro
externals reproduces the prior bundling behaviour.

https://claude.ai/code/session_012YWscdohmouZHhZ7otKnqh
@TheMeinerLP TheMeinerLP merged commit 88ec5fe into main May 15, 2026
3 of 5 checks passed
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

Successfully merging this pull request may close these issues.

2 participants