pi0 / nitro-cloudflare-dev

Enable access to the Cloudflare runtime bindings in development server of Nitro and Nuxt
MIT License
73 stars 4 forks source link

Support `environment` configuration #27

Closed Perdolique closed 3 months ago

Perdolique commented 3 months ago

The existing plugin doesn't work with multi-environment configurations. To get the correct binding from getPlatformProxy in this case we need to specify environment.

Example wrangler.toml

name = "woof"
compatibility_date = "2024-06-29"
pages_build_output_dir = "./dist"

[[env.production.d1_databases]]
binding = "DB"
database_name = "woof-prod"
database_id = "prod"

[[env.preview.d1_databases]]
binding = "DB"
database_name = "woof-stage"
database_id = "stage"