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: 5617264

@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

@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 🔥

@atinux atinux requested a review from RihanArfan January 9, 2026 09:32
@atinux
Copy link
Contributor

atinux commented Jan 9, 2026

I will let @RihanArfan have a deep review at it once he's back from holidays :)

- Add `hub.remote` option to use production Cloudflare bindings during dev
- Fix Promise bindings from nitro-cloudflare-dev via getPlatformProxy
- Change db import to dynamic to handle async bindings
- Add isRemoteDev helper to reduce duplication
- Fail loudly when remote bindings fail (no silent stub fallback)
- Fix proxy.dispose() to actually call the function

Fixes nuxt-hub#741
Fixes nuxt-hub#743
@onmax onmax force-pushed the fix/nitro-cloudflare-dev-bindings branch from 07128ba to 5617264 Compare January 9, 2026 10:39
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