Skip to content

Cannot deploy NuxtHub to Cloudflare using Turso, always forced to D1 driver #841

@schplitt

Description

@schplitt

Describe the bug
When deploying a NuxtHub project to Cloudflare (Workers/Pages), it is not possible to use Turso/libsql as the production database, even when explicitly setting driver: 'libsql' and providing the correct TURSO_DATABASE_URL and TURSO_AUTH_TOKEN environment variables at build time. The deployment logic always overwrites the driver with 'd1' when hub.hosting includes 'cloudflare', making it impossible to use Turso in Cloudflare production environments.

Even though it should be correctly configured, I always see an error with:

[nuxt-hub] DB binding not found

in the logs during deployment or runtime.

Steps to reproduce

  1. Set up a NuxtHub project with the following config:
    hub: {
      db: {
        dialect: 'sqlite',
        driver: 'libsql',
        connection: {
          url: process.env.TURSO_DATABASE_URL,
          authToken: process.env.TURSO_AUTH_TOKEN
        }
      }
    }
  2. Add Cloudflare preset or allow automatic hosting detection
  3. Set TURSO_DATABASE_URL and TURSO_AUTH_TOKEN as build environment variables in Cloudflare dashboard
  4. Deploy project to Cloudflare Workers/Pages
  5. Observe that NuxtHub always sets the driver to 'd1', ignoring the explicit Turso/libsql config
  6. Log output shows [nuxt-hub] DB binding not found error, even when all variables are set.

Expected behavior
Turso/libsql should be used as the production database if configured and environment variables are set. The current behavior forces Cloudflare D1 for all Cloudflare deployments, making it impossible to use Turso as the primary DB provider on CF.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions