-
Notifications
You must be signed in to change notification settings - Fork 104
Description
Description
There is a "split-brain" behavior between blob.handleUpload() and blob.serve() when forcing the local filesystem driver in development environments that contain a wrangler.jsonc file.
The Setup:
I have a Nuxt 4 app using the cloudflare-module preset. During standard local development (nuxt dev), I want to bypass R2 entirely and use the local filesystem. I explicitly configured the FS driver:
export default defineNuxtConfig({
hub: {
blob: { driver: 'fs', dir: '.data/blob' }
}
})The Bug:
- When I call
blob.handleUpload(), NuxtHub correctly respects the config. The terminal logsℹ hub:blob using fs driverand successfully writes the file to.data/blob/test-uploads/image.png. - However, when I immediately call
blob.serve(event, pathname), it crashes with a 500 error:R2 binding "BLOB" not found.
Stack Trace:
Error: R2 binding "BLOB" not found
at getBucket (.../@nuxthub/core/dist/blob/lib/drivers/cloudflare-r2.mjs:18:13)
at Object.getArrayBuffer (.../@nuxthub/core/dist/blob/lib/drivers/cloudflare-r2.mjs:55:22)
at Object.serve (.../@nuxthub/core/dist/blob/lib/storage.mjs:20:40)
Why it's happening:
It appears that while the upload utility respects the explicit driver: 'fs' override, the serve() utility aggressively auto-detects the wrangler.jsonc in the root and attempts to use the cloudflare-r2 driver to fetch the BLOB binding. Since I am running a standard local dev server (no Miniflare/--remote), the binding doesn't exist and it throws an error, completely ignoring the fs fallback where the file actually lives.
Expected Behavior:
blob.serve() should respect the explicit { driver: 'fs' } configuration defined in nuxt.config.ts, just like blob.handleUpload() does, rather than falling back to R2 auto-detection.
Temporary Workaround:
Manually checking environment variables to bypass blob.serve() and stream the file via Node's fs.createReadStream during local development.