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

generate.routes option not picked up when providing an async function in rc-13 #15425

Closed
kilobyte2007 opened this issue Nov 9, 2022 · 3 comments

Comments

@kilobyte2007
Copy link

Environment

Nuxi 3.0.0-rc.13
RootDir: /home/projects/github-uyhfhu
Nuxt project info:


  • Operating System: Linux
  • Node Version: v16.14.2
  • Nuxt Version: 3.0.0-rc.13
  • Nitro Version: 0.6.1
  • Package Manager: npm@7.17.0
  • Builder: vite
  • User Config: generate
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-uyhfhu?file=nuxt.config.ts

Please try running the npm run generate command in this reproduction example.

Describe the bug

The generate command was working fine in rc-12 when async routes were provided to the generate command.
In rc-13 it no longer generates the specified routes (you can see only 200 and 400 routes are generated instead of the provided routes).

On another note: Is it possible to disable the crawler altogether and make nuxt generate just the pages that I provide in the generate.routes option? It doesn't seem to be such an option now.

Also, typescript reports an error for when I specify an async function for routes.

Additional context

No response

Logs

❯ npm run generate
$ nuxt generate
Nuxi 3.0.0-rc.13
Nuxt 3.0.0-rc.13 with Nitro 0.6.1
ℹ Client built in 1064ms
ℹ Building server...
✔ Server built in 339ms
✔ Generated public .output/public
ℹ Initializing prerenderer
ℹ Prerendering 3 initial routes with crawler
  ├─ async routes() {
      return await Promise.resolve(['/', '/pricing']);
    } (undefinedms) (TypeError [ERR_INVALID_URL]: Invalid URL)
  ├─ /200.html (36ms) 
  ├─ /404.html (1ms) 
✔ You can now deploy .output/public to any static hosting!
@danielroe
Copy link
Member

Nuxt 3 does not do anything with a function provided in generate.routes.

What did change in rc12 is that we stopped generating / by default. But this is fixed in the edge channel via nuxt/framework#8782.

If you want to disable crawler, set nitro.prerender.crawlLinks to false. If you want to add routes manually, add to nitro.prerender.routes. If you need an async function, see #13949.

@danielroe danielroe closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2022
@kilobyte2007
Copy link
Author

Thanks a lot for the answer! Got it now and it works with the solution you provided. I was misguided by this config option existing in the v3 docs.

I also figured it would be possible to specify the routes statically, without async when using defineNuxtConfig(async () => {}), but it seems to be deprecated. What will be the go-to solution for setting async runtimeConfig parameters in this case?

Thanks a lot for your work on Nuxt!

Copy link
Member

@kilobyte2007 In that case, I would use a module.

@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe transferred this issue from nuxt/framework Jan 19, 2023
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