Skip to content

Cloudflare deployment completely fails when app.baseURL is set (dump SQL path mismatch) #3607

@piotrjoniec

Description

@piotrjoniec

Environment

  • Operating System: Darwin
  • Node Version: v20.19.3
  • Nuxt Version: 4.2.1
  • CLI Version: 3.30.0
  • Nitro Version: 2.12.9
  • Package Manager: pnpm@10.16.1
  • Builder: -
  • User Config: modules, devServer, compatibilityDate, app, content, nitro
  • Runtime Modules: @nuxt/content@3.8.0, @nuxt/image@2.0.0
  • Build Modules: -

Version

v3

Reproduction

The description should be clear.

Description

When setting a custom app.baseURL in nuxt.config, the content dump .sql files are generated under that base path during build.

Example:

// nuxt.config.ts
export default defineNuxtConfig({
  app: {
    baseURL: '/docs/'
  }
})

After running nuxi build, the dump files are generated here:

.output/public/docs/dump.docs.sql
.output/public/docs/dump.landing.sql

However, the Cloudflare database handler currently tries to read the dump files from the root of the public directory:

.output/public/dump.docs.sql
.output/public/dump.landing.sql

Reference:
https://github.com/nuxt/content/blob/main/src/runtime/presets/cloudflare/database-handler.ts

This mismatch causes the Cloudflare deployment to fail completely, as the handler cannot find the database dump files when app.baseURL is configured.

  (error) Database integrity check failed TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, TypedArray, ArrayBuffer, SharedArrayBuffer, or Array or an Array-like Object. Received undefined
  (error) [request error] [unhandled] [POST] http://localhost/atlas/__nuxt_content/docs/query?v=v3.5.0--1iaEqfb6N2B9swy1YIvL1PTivtSAKI7ZDcLKW5K641I
 {
  message: 'D1_ERROR: no such table: _content_docs: SQLITE_ERROR',
  statusCode: 500
}

After manually moving the files to the root public directory and redeploying, everything works correctly. The database handler successfully loads the dumps and the site runs without any errors.

Possible fix

The Cloudflare database handler should respect the configured app.baseURL when looking for the dump .sql files, so that it can correctly locate them under .output/public/[baseURL]/.

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