core icon indicating copy to clipboard operation
core copied to clipboard

@nuxthub/core prevent deploying to other sites

Open dearfad opened this issue 8 months ago • 6 comments

When @nuxthub/core enabled in nuxt.config.ts, vercel netlify and other providers failed deploying automatic by github with error message

[error] [nuxt:hub] NuxtHub is only compatible with the cloudflare_pages, cloudflare_module or cloudflare_durable presets.

So I must enable @nuxthub/core to wait for cloudflare pages ready, then delete @nuxthub/core and push code to github again, is there any method to solve it,

I tried this way in hub env with HOSTING_PROVIDER, but failed again. modules: [ '@nuxt/eslint', process.env.HOSTING_PROVIDER === 'nuxthub' ? '@nuxthub/core' : '', ],

dearfad avatar Apr 01 '25 13:04 dearfad

What is your use case to deploy the same site on many providers?

atinux avatar Apr 11 '25 15:04 atinux

I have a similar case (2 deployments).

I have a Nuxt app deployed on NuxtHub (ie Cloudflare), which is my official production deploy for end-users. The app also has a registered instance on Nuxt Studio, to have a nice convenient place to work on content, and preview it. For this there's a Github Pages deployment.

If I maintain @nuxthub/core in modules, then the GH Pages deploy fails.

nuxt.config.ts

modules: ['@nuxt/content', '@nuxt/ui', "@nuxt/image", '@pinia/nuxt', 'nuxt-security'
    '@nuxthub/core',
]
Run npx nuxi build --preset github_pages
[log] [ nuxi ] Nuxt 3.16.1 with Nitro 2.11.8
Error:  [nuxt:hub] NuxtHub is only compatible with the `cloudflare_pages`, `cloudflare_module` or `cloudflare_durable` presets.
Error: Process completed with exit code 1.

Commenting-out @nuxthub/core, both deployments seem to work fine (so far?), although I lose whatever benefits of @nuxthub/core.

nuxt.config.ts

modules: ['@nuxt/content', '@nuxt/ui', "@nuxt/image", '@pinia/nuxt', 'nuxt-security'
    //'@nuxthub/core',
]

If this pattern (Nuxthub-for-prod + Nuxt-Studio-GH-Pages-for-editing) has already been proven working prior to me, then perhaps I still have an implementation issue I'm overlooking.

For the time being I'm just excluding @nuxthub/core, however it would be awesome if this could be enabled conditionally.

Other discussions online point to having an enable/disable property for a module's options object in Nuxt config.

kalnode avatar Apr 13 '25 01:04 kalnode

In recent 2 or more days, even without '@nuxthub/core' in nuxtconfig modules, my project was successfully deployed to cloudflare through nuxthub, However, it's still unclear whether I should include '@nuxthub/core' in nuxt.config.ts modules.

for freeeeeeeee and zero-config , it's effortless to deploy to many providers, now I use EdgeOne Pages for my main site because it offers the best speed, but nitro server doesn't support it yet , I deploy static site there, and use cloudflare, vercel or netlify api.

dearfad avatar Apr 13 '25 08:04 dearfad

The @nuxthub/core give you access to all the server utils (hubDatabase(), hubAI(), etc.) as well as making sure that everything works seamlessly on Workers (even though Nuxt works already great in it without config).

You should be able to add a condition to conditionally add the module based on an environment variable though

atinux avatar Apr 13 '25 09:04 atinux

Yes, some condition loading for modules would be best, then it's explicit & clear in nuxt.config.

Side note: Looked at the logs for my "Nuxthub deploy" github action, looks like the @nuxthub/core module is added dynamically!

(log output for gh action)

Run npx nuxthub@latest ensure
  
[log] NuxtHub CLI
[info] @nuxthub/core module is not installed, installing...

kalnode avatar Apr 13 '25 14:04 kalnode