Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@onmax
Copy link
Contributor

@onmax onmax commented Dec 19, 2025

Fixes #741
Fixes #743

Problem

  1. nitro-cloudflare-dev sets globalThis.__env__ as a Promise initially. NuxtHub accesses globalThis.__env__?.DB synchronously which fails.
  2. Users need a way to connect to production Cloudflare bindings during local development.

Solution

Adds hub.remote: true option to use production Cloudflare bindings (D1, KV, R2) during local development using wrangler's getPlatformProxy().

Reproduction

git clone --depth 1 --filter=blob:none --sparse https://github.com/onmax/repros.git
cd repros && git sparse-checkout set nuxthub-741-fixed
cd nuxthub-741-fixed && pnpm i && CLOUDFLARE_ACCOUNT_ID=<your-account-id> pnpm dev
# Visit http://localhost:3000/api/counter

The -fixed folder includes a pnpm patch with the fix.

Configuration

// nuxt.config.ts
export default defineNuxtConfig({
  hub: {
    remote: true,  // Use production bindings during dev
    kv: { namespaceId: 'your-kv-id' },
  }
})

@vercel
Copy link

vercel bot commented Dec 19, 2025

@onmax is attempting to deploy a commit to the NuxtLabs Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 19, 2025

npm i https://pkg.pr.new/@nuxthub/core@742

commit: 07128ba

@onmax onmax force-pushed the fix/nitro-cloudflare-dev-bindings branch from 4d07903 to 757e725 Compare December 19, 2025 15:57
@atinux
Copy link
Contributor

atinux commented Dec 19, 2025

Thanks for the help on this @onmax

Did you see that with latest Nitro compat, we don't need to install nitro-cloudflare-dev anymore?
https://nitro.build/deploy/providers/cloudflare#dev-preset

- Add hub.remote: true option to use production Cloudflare bindings during local development
- Uses wrangler's getPlatformProxy() to inject remote bindings (D1, KV, R2)
- Auto-generates wrangler.toml with remote = true for all configured bindings
- Simplify Promise handling in cloudflare-r2 driver
- Remove nitro-cloudflare-dev dependency (use native approach)

Closes nuxt-hub#743
@onmax
Copy link
Contributor Author

onmax commented Dec 19, 2025

I will be offline for the next week. Please feel free to iterate or close this PR if a better solution emerges.

Merry Christmas to the whole team! And well done on this new NuxtHub; I'm really excited about everything that's happening in the Nuxt ecosystem! 2026 will be 🔥

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.

Cloudflare remote bindings flags D1 bindings not accessible in dev with nitro-cloudflare-dev

2 participants