Skip to content

Incorrect NuxtHub version handling #3679

@matveyson

Description

@matveyson

Environment

  • Node.js version v22.14.0
  • Package manager pnpm 10.14.0
  • Nuxt version 4.2.2 - Nitro version 2.12.9 - Builder vite 7.3.1
  • nuxt/content v3.10.0
  • nuxt/hub @nuxthub/core 0.10.4

Version

v3.10.0

Reproduction

Deploy Nuxt Content (3.10) with Nuxt Hub (0.10.4) on, say, Vercel (anything else than cloudflare)

Description

There is a logic bug in handling the huxthub version:

const nuxthubVersion = nuxt.options.hub?.database === true ? 0.9 : 0.10
// NuxtHub <= 0.9
if (nuxthubVersion <= 0.9) {
if (nitroConfig.runtimeConfig?.content?.database?.type === 'sqlite') {
logger.warn('Deploying with NuxtHub < 1 requires using D1 database, switching to D1 database with binding `DB`.')
nitroConfig.runtimeConfig!.content!.database = { type: 'd1', bindingName: 'DB' }
}
}
else if (nuxthubVersion >= 0.10) {

For nuxthub 0.10.* (current latest), nuxthubVersion will be assigned a value of 0.10 which is 0.1 (surprise surprise), therefore it falls under a <= 0.9 brach and the correct else if brach is not executed. In the PR, I have replaced this numeric check with a check similar to the one in the setup method

// NuxtHub <= 0.9
if (nuxtOptions.hub?.database === true) {
options.database ||= { type: 'd1', bindingName: 'DB' }
}
else if (typeof nuxtOptions.hub?.db === 'string' && typeof hubDb === 'object') {

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