Environment
- Package: "@nuxthub/core"
- Version: "0.10.7"
- Hosting: Cloudflare
- Feature: "hub.blob" with "cloudflare-r2"
Describe the bug
When using NuxtHub blob storage with the Cloudflare R2 driver, NuxtHub auto-generates the "r2_buckets" entry in the Nitro/Wrangler config.
However, the generated binding only includes:
{
"binding": "BLOB",
"bucket_name": "my-bucket"
}
It does not include the R2 "jurisdiction" property, even though "jurisdiction" is a valid Wrangler R2 bucket binding field.
This is a problem for jurisdictional R2 buckets, for example EU buckets.
Current behavior
Given a NuxtHub blob config like:
export default defineNuxtConfig({
hub: {
blob: {
driver: 'cloudflare-r2',
bucketName: 'my-eu-bucket',
binding: 'BLOB',
jurisdiction: 'eu'
}
}
})
The generated Wrangler config does not include "jurisdiction".
Expected behavior
NuxtHub should preserve/pass through the "jurisdiction" option into the generated "r2_buckets" entry:
{
"r2_buckets": [
{
"binding": "BLOB",
"bucket_name": "my-eu-bucket",
"jurisdiction": "eu"
}
]
}
Relevant code
In "src/blob/setup.ts", the R2 binding is currently generated like this:
addWranglerBinding(nuxt, 'r2_buckets', {
binding: blobConfig.binding || 'BLOB',
bucket_name: blobConfig.bucketName
})
This only maps "binding" and "bucketName", so "jurisdiction" cannot make it into the generated Wrangler config.
Suggested fix
Extend the Cloudflare R2 blob config type and binding generation to support "jurisdiction", for example:
export type CloudflareR2BlobConfig = {
driver: 'cloudflare-r2'
bucketName?: string
jurisdiction?: string
} & CloudflareDriverOptions
And then include it when generating the Wrangler binding:
addWranglerBinding(nuxt, 'r2_buckets', {
binding: blobConfig.binding || 'BLOB',
bucket_name: blobConfig.bucketName,
jurisdiction: blobConfig.jurisdiction
})
It may also be worth supporting other valid R2 binding properties, such as "preview_bucket_name" and "experimental_remote".
Workaround
Manually define the R2 binding in "nitro.cloudflare.wrangler.r2_buckets" with the same binding name:
export default defineNuxtConfig({
hub: {
blob: {
driver: 'cloudflare-r2',
bucketName: 'my-eu-bucket',
binding: 'BLOB'
}
},
nitro: {
cloudflare: {
wrangler: {
r2_buckets: [
{
binding: 'BLOB',
bucket_name: 'my-eu-bucket',
jurisdiction: 'eu'
}
]
}
}
}
})
Environment
Describe the bug
When using NuxtHub blob storage with the Cloudflare R2 driver, NuxtHub auto-generates the "r2_buckets" entry in the Nitro/Wrangler config.
However, the generated binding only includes:
It does not include the R2 "jurisdiction" property, even though "jurisdiction" is a valid Wrangler R2 bucket binding field.
This is a problem for jurisdictional R2 buckets, for example EU buckets.
Current behavior
Given a NuxtHub blob config like:
The generated Wrangler config does not include "jurisdiction".
Expected behavior
NuxtHub should preserve/pass through the "jurisdiction" option into the generated "r2_buckets" entry:
Relevant code
In "src/blob/setup.ts", the R2 binding is currently generated like this:
This only maps "binding" and "bucketName", so "jurisdiction" cannot make it into the generated Wrangler config.
Suggested fix
Extend the Cloudflare R2 blob config type and binding generation to support "jurisdiction", for example:
And then include it when generating the Wrangler binding:
It may also be worth supporting other valid R2 binding properties, such as "preview_bucket_name" and "experimental_remote".
Workaround
Manually define the R2 binding in "nitro.cloudflare.wrangler.r2_buckets" with the same binding name: