all routes 404 at prerender

Why with this
nitro: {
prerender: {
routes: [
'/en/blog/poder-fragancias',
'/es/blog/poder-fragancias',
'/pt/blog/poder-fragancias'
],
crawlLinks: false,
failOnError: false
},
}
nitro: {
prerender: {
routes: [
'/en/blog/poder-fragancias',
'/es/blog/poder-fragancias',
'/pt/blog/poder-fragancias'
],
crawlLinks: false,
failOnError: false
},
}
I get all 404 like so
ℹ Initializing prerenderer
ℹ Prerendering 82 routes
├─ /es/blog/poder-fragancias (1967ms)
│ └── [404] Not Found
├─ /en/blog/poder-fragancias (2049ms)
│ └── [404] Not Found
├─ /pt/blog/poder-fragancias (2112ms)
│ └── [404] Not Found
ℹ Prerendered 1 routes in 18.738 seconds
ℹ Initializing prerenderer
ℹ Prerendering 82 routes
├─ /es/blog/poder-fragancias (1967ms)
│ └── [404] Not Found
├─ /en/blog/poder-fragancias (2049ms)
│ └── [404] Not Found
├─ /pt/blog/poder-fragancias (2112ms)
│ └── [404] Not Found
ℹ Prerendered 1 routes in 18.738 seconds
And only one route is prerendered instead of 82? All these routes exists you can c heck yourself at ondanovia.com I'm using nuxt/content and nuxt/i18n Both the configuration and the log are an extract of the actually existing 82 routes.
3 Replies
kapa.ai
kapa.ai4mo ago
Hi @learntheropes. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The 404 errors during prerendering, despite specifying the routes in nitro.prerender.routes, usually indicate that Nuxt cannot find or generate the content for those routes at build time. Here are the most likely causes and solutions based on the knowledge sources: 1. Dynamic Content Not Discoverable at Build Time
If your blog pages (e.g., /en/blog/poder-fragancias) are generated dynamically—such as via Nuxt Content or fetched from an API—they must be available and resolvable during the build. If the content is fetched asynchronously or depends on runtime data, the prerenderer will not find it and will return 404s. This is a common issue when using Nuxt Content with dynamic routes and i18n. 2. Crawl Links Disabled
You have set crawlLinks: false, which means Nuxt will not crawl your site for additional links. Only the routes explicitly listed in routes will be prerendered. This is fine, but it means you must ensure all those routes are resolvable at build time. 3. Nuxt Content and i18n Integration
When using @nuxt/content and @nuxtjs/i18n, you need to ensure that all localized content files exist and are accessible for each language/route combination at build time. If a content file is missing for a locale, the route will 404 during prerender. 4. How to Fix
- Check Content Files: Make sure that the content for each language and slug exists in your content/ directory and is named correctly for each locale. - Ensure Data Availability: If you fetch data from an external source, ensure it is available at build time. - Use prerenderRoutes or Nuxt Hooks: If your routes are generated dynamically (e.g., from a CMS or API), use the prerender:routes Nuxt hook to programmatically add routes before prerendering starts:
export default defineNuxtConfig({
hooks: {
async 'prerender:routes'(ctx) {
// Fetch your dynamic routes here and add them
const dynamicRoutes = [/* ...fetch or generate your routes... */]
for (const route of dynamicRoutes) {
ctx.routes.add(route)
}
}
}
})

export default defineNuxtConfig({
hooks: {
async 'prerender:routes'(ctx) {
// Fetch your dynamic routes here and add them
const dynamicRoutes = [/* ...fetch or generate your routes... */]
for (const route of dynamicRoutes) {
ctx.routes.add(route)
}
}
}
})

Runtime prerender configuration - Check Nuxt Content Dynamic Routing: For dynamic content, ensure you follow the Nuxt Content dynamic routing guide to expose all routes to the prerenderer. 5. Sitemap and Dynamic URLs
If you use a sitemap, you may need to provide an API source for dynamic URLs, as the sitemap module cannot discover them automatically unless you configure it to do so nuxt-sitemap does not find pre-rendered pages. Summary:
The 404s occur because the prerenderer cannot find the content for those routes at build time. Double-check your content files, ensure all data is available at build, and consider using the prerender:routes hook to programmatically add dynamic routes if needed. This is especially important when using Nuxt Content and i18n, as each localized route must have corresponding content available during the build process. If you need more specific troubleshooting, please provide details on how your content is structured and how routes are generated. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@405152252207169536> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
learntheropes
learntheropesOP4mo ago
async 'prerender:routes'(ctx) { const dynamicRoutes = prerenderRoutes for (const route of dynamicRoutes) { ctx.routes.add(route) } }, ``` I'm 1005 sure all the routes exists. Each page is localized with i18n prefix strategy and the page load the content using const article = await queryContent('blog', slug).findOne(); But even with the new hook I still get all 404 can u assist me farther @kapa.ai? the issue is with @sidebase/nuxt-auth I still have to find a workaround

Did you find this page helpful?