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

Problem with route rules in nuxt.config #27243

Closed
BogdanPirozhok opened this issue May 16, 2024 · 3 comments
Closed

Problem with route rules in nuxt.config #27243

BogdanPirozhok opened this issue May 16, 2024 · 3 comments

Comments

@BogdanPirozhok
Copy link

BogdanPirozhok commented May 16, 2024

Good afternoon. Thanks for your attention, any help would be appreciated.

I have these rules in nuxt.config:

routeRules: {
    '/feed': { ssr: true, swr: false },
    '/feed/**': { swr: true }
},

So what I'm trying to accomplish is:

  • /feed - this page is rendered dynamically using SSR.
  • /feed/[slug] - dynamic pages with this pathname will be rendered statically with SWR

Unfortunately, in my case, it doesn't work, both routers generate static. This happens both in production environment and in development mode

@nuxtbot nuxtbot changed the title Problem with route rules in nuxt.config Here is the translation: "Route rules in the nuxt.config file are giving me trouble. I have the same route for two components, and when I try to navigate to one of them, the other one is displayed instead. I've tried rearranging the order of the route rules, but it doesn't make a difference. I'm not sure why this is happening and how to fix it." May 16, 2024
@BogdanPirozhok BogdanPirozhok changed the title Here is the translation: "Route rules in the nuxt.config file are giving me trouble. I have the same route for two components, and when I try to navigate to one of them, the other one is displayed instead. I've tried rearranging the order of the route rules, but it doesn't make a difference. I'm not sure why this is happening and how to fix it." Problem with route rules in nuxt.config May 16, 2024
@danielroe
Copy link
Member

Does it work if you try:

routeRules: {
    '/feed': { swr: false, cache: false },
    '/feed/**': { swr: true }
},

@BogdanPirozhok
Copy link
Author

'/feed': { swr: false, cache: false },
    '/feed/**': { swr: true }

It works amazingly. Thank you very much. I think this example should be covered in the documentation

@danielroe
Copy link
Member

A PR would be very welcome! Also I think we likely need to make this behaviour more intuitive - see unjs/nitro#887.

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

2 participants