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

Prerender.Routes problem dealing with trailing slashes #24392

Closed
lassediercks opened this issue Nov 21, 2023 · 5 comments · Fixed by #24516
Closed

Prerender.Routes problem dealing with trailing slashes #24392

lassediercks opened this issue Nov 21, 2023 · 5 comments · Fixed by #24516

Comments

@lassediercks
Copy link

Environment


  • Operating System: Linux
  • Node Version: v18.18.0
  • Nuxt Version: 3.8.1
  • CLI Version: 3.9.1
  • Nitro Version: 2.7.2
  • Package Manager: yarn@1.22.19
  • Builder: -
  • User Config: nitro
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-rqmpdd?file=pages%2F[..._].vue,layouts%2Fdefault.vue,nuxt.config.ts

  1. Open the reproduction in a new window
  2. Click on any of the links
  3. Content has been fetched, even when it should be pregenerated should appear in console even though all routes should've been prerendered

Describe the bug

When adding routes with a trailing slash to nitro.prerender.routes the prerendered content is not used and the page is refetched instead.

Additional context

The behaviour does not seem to appear with nuxt version 3.6.5

https://stackblitz.com/edit/github-rqmpdd-ih3byq?file=pages%2F[..._].vue,nuxt.config.ts,layouts%2Fdefault.vue,pages%2Findex.vue

Logs

No response

Copy link

stackblitz bot commented Nov 21, 2023

@danielroe danielroe added nitro and removed nitro labels Nov 22, 2023
@danielroe
Copy link
Member

If you log the cacheKey you have created you will see that when prerendering it is /evan/ but in production without the trailing slash, the cache key is /evan. This is because your key depends on the trailing slash. Instead, you should ensure you do not depend on the trailing slash for your key. You can use withoutTrailingSlash from ufo as a helpful utility to strip it if you really need to use the path.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2023
@lassediercks
Copy link
Author

lassediercks commented Nov 22, 2023

Hey @danielroe thanks for the quick answer,

the cacheKey variable indeed had the trailing slash included.
That variable was not used as the cache key though.

Instead the route param is used as the cache key. Only including a single string anthony,daniel,evan

Sorry for the confusion, I've updated the reproduction

@danielroe danielroe reopened this Nov 22, 2023
@alihardan
Copy link

alihardan commented Nov 26, 2023

Same problem. It happen after upgrading to Nuxt 3.8.1. I'm temporarily reverting to 3.8.0.

@lassediercks
Copy link
Author

lassediercks commented Nov 27, 2023

For me it started with 3.7.0

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

Successfully merging a pull request may close this issue.

3 participants