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

Deployment to Cloudflare Pages broken with new Nuxt 3.8 app manifest feature #1844

Closed
AaronBeaudoin opened this issue Oct 20, 2023 · 4 comments · Fixed by #1859
Closed

Deployment to Cloudflare Pages broken with new Nuxt 3.8 app manifest feature #1844

AaronBeaudoin opened this issue Oct 20, 2023 · 4 comments · Fixed by #1859
Assignees
Labels
bug Something isn't working nuxt preset:cloudflare

Comments

@AaronBeaudoin
Copy link
Contributor

AaronBeaudoin commented Oct 20, 2023

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

In Nuxt 3.8 a new feature was introduced which adds a new /_nuxt/builds/meta/<buildId>.json in the build output directory. This causes the following two new entries to be added to nitro.options.publicAssets:

{
  ...
  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
    }
  ]
}

The Cloudflare Pages preset then "copies" these over when generating a _routes.json file:

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

This results in the following error during deployment:

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.

I originally created nuxt/nuxt#23796 when I discovered this issue, but according to the maintainer who responded it is Nitro's responsibility to ensure that the overlapping URLs created in nitro.options.publicAssets are correctly handled when creating _routes.json.

Additional context

For now this issue can be avoided with experimental: { appManifest: false } in nuxt.config.ts. However, this issue will come back again if any other overlapping URLs ever make it into nitro.options.publicAssets.

Logs

No response

@DavidDeSloovere
Copy link
Contributor

DavidDeSloovere commented Oct 26, 2023

When you use wrangler to create a nuxt application, you can also see this error.
That way you don't need to set up a build or a repo.

npm create cloudflare@latest my-nuxt-app -- --framework=nuxt

image

@favna
Copy link

favna commented Oct 27, 2023

@atinux This was already mentioned in the posts' "Additional context", along with its downsides. Commenting the same again separately may lead to people incorrectly assuming it's a good long-term solution.

@atinux
Copy link
Collaborator

atinux commented Oct 28, 2023

@favna read too fast sorry about this, deleted the comment to avoid any downsides.

@pi0 pi0 closed this as completed in #1859 Oct 28, 2023
@pi0
Copy link
Member

pi0 commented Oct 28, 2023

The fix is released on nitro@2.7.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working nuxt preset:cloudflare
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants