Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt 3.8 can no longer deploy to Cloudflare Pages #23796

Closed
AaronBeaudoin opened this issue Oct 19, 2023 · 9 comments
Closed

Nuxt 3.8 can no longer deploy to Cloudflare Pages #23796

AaronBeaudoin opened this issue Oct 19, 2023 · 9 comments

Comments

@AaronBeaudoin
Copy link

Environment

  • Operating System: Darwin
  • Node Version: v18.18.2
  • Nuxt Version: 3.8.0
  • CLI Version: 3.9.1
  • Nitro Version: 2.7.0
  • Package Manager: npm@9.8.1
  • Builder: -
  • User Config: nitro
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/AaronBeaudoin/nuxt-3-issue-1

Describe the bug

Deploying to Cloudflare Pages worked fine on 3.7.4, but on 3.8 it fails with this error:

Error: Failed to publish your Function. Got error: Error 8000057: Overlapping rules in _routes.json are not allowed. Rule "/_nuxt/builds/*" is overlapped by "/_nuxt/*". Remove one of the rules to continue.

Just fork my reproduction above and try to deploy it to Cloudflare Pages and you should get the same error.

Additional context

No response

Logs

No response

@danielroe
Copy link
Member

This is likely an upstream issue with Nitro caused by overlapping publicAssetsDirs.

cc: @pi0

@AaronBeaudoin
Copy link
Author

@danielroe try rolling back to Nuxt 3.7.4 and according to nuxi info you should still be using Nitro 2.7.0. When I tried this, my deployment worked. Based on that it would seem that Nitro isn't the problem.

@cosbgn
Copy link

cosbgn commented Oct 19, 2023

It seems that the error comes from this:

{
  "version": 1,
  "include": [
    "/*"
  ],
  "exclude": [
    "/_nuxt/*",
    "/_nuxt/builds/*",
    "/_nuxt/builds/meta/*",

Since it has: "/_nuxt/*" it shouldn't have "/_nuxt/builds/*" or "/_nuxt/builds/meta" as those are counted as overlapping

@AaronBeaudoin
Copy link
Author

@danielroe I dug into this a bit and I found that by the time Nitro even starts running the compiled() hook in the preset, nitro.options.publicAssets already has the entries which Nitro is simply "copying" over:

{
  ...
  publicAssets: [
    {
      dir: '/Users/<me>/Projects/test/test-nuxt-3/.nuxt/manifest/meta',
      maxAge: 31536000,
      baseURL: '/_nuxt/builds/meta',
      fallthrough: false
    },
    {
      dir: '/Users/<me>/Projects/test/test-nuxt-3/.nuxt/manifest',
      maxAge: 1,
      baseURL: '/_nuxt/builds',
      fallthrough: false
    },
    {
      dir: '/Users/<me>/Projects/test/test-nuxt-3/.nuxt/dist/client/_nuxt',
      maxAge: 31536000,
      baseURL: '/_nuxt',
      fallthrough: false
    },
    {
      dir: '/Users/<me>/Projects/test/test-nuxt-3/public',
      baseURL: '/',
      fallthrough: true,
      maxAge: 0
    }
  ]
}

Since they started appearing in Nuxt 3.8, wouldn't this change be the most likely culprit?
https://github.com/nuxt/nuxt/blame/main/packages/nuxt/src/core/nitro.ts#L136

@danielroe
Copy link
Member

@AaronBeaudoin I understand that it might seem like that. #21641 added the extra directory to publicAssetsDirs, but Nitro is generating the invalid JSON for CF and that is why it needs to be fixed in Nitro...

@AdiRishi
Copy link

AdiRishi commented Oct 20, 2023

Just ran into this myself. Is the next step here to create an issue in the Nitro github repo?

@Bjornftw
Copy link

Bjornftw commented Oct 20, 2023

If you don't want to use the new experimental manifest feature, add experimental: { appManifest: false } to your defineNuxtConfig. This will make the deployment on Cloudflare work again.

CleanShot 2023-10-20 at 12 45 23

@danielroe
Copy link
Member

let's track in unjs/nitro#1844

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Oct 23, 2023
@pi0
Copy link
Member

pi0 commented Oct 28, 2023

The fix is released on nitro@2.7.2 you can use npx nuxi upgrade to have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants