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

[v3] Page not found on preview after generate #3043

Open
brokuka opened this issue Jan 26, 2025 · 3 comments
Open

[v3] Page not found on preview after generate #3043

brokuka opened this issue Jan 26, 2025 · 3 comments

Comments

@brokuka
Copy link

brokuka commented Jan 26, 2025

Environment


  • Operating System: Windows_NT
  • Node Version: v22.12.0
  • Nuxt Version: 3.15.3
  • CLI Version: 3.20.0
  • Nitro Version: 2.10.4
  • Package Manager: pnpm@9.15.4
  • Builder: -
  • User Config: devtools, future, modules, eslint, compatibilityDate
  • Runtime Modules: @nuxt/eslint@0.7.5, template-copyright@1.0.1, @nuxt/content@3.0.0, nuxt-security@2.1.5
  • Build Modules: -

Version

v3

Reproduction

// ~/pages/[...slug].vue

<script setup lang="ts">
const route = useRoute()

const { data } = await useAsyncData(route.path, () => queryCollection('docs').path(route.path).first())
</script>

<template>
  <ContentRenderer v-if="data" :value="data" />
</template>

Content

Add some pages in content folder.

For example:

Image

Description

Note

Using nuxt build all pages works as expected.

Getting 404 error on preview after generate nuxt generate. Works only page root /, for example if you have blog page there will be throwing error.

Additional context

No response

Logs

@thorge
Copy link

thorge commented Feb 1, 2025

Same here. Maybe someone can elaborate on how to make static builds work?

In dev mode everything works fine. I tried both ssr: true/false. Pages are empty after build.

Update: It works now, I forgot a client-only tag 🤦

@undefinedhuman
Copy link

Hi, facing the same issue, only thing that works for me is defining the final paths in the nitro prerender block:

  nitro: {
    static: true,
    prerender: {
      routes: ["/sitemap.xml", "/", "/docs/getting-started/installation"],
    },
  },

@thorge
Copy link

thorge commented Feb 10, 2025

Hi, facing the same issue, only thing that works for me is defining the final paths in the nitro prerender block:

nitro: {
static: true,
prerender: {
routes: ["/sitemap.xml", "/", "/docs/getting-started/installation"],
},
},

@undefinedhuman You might want to try to crawl your links when pre-rendering. This only works, if there a links pointing to your pages:

// nuxt.config.ts
nitro: {
  prerender: {
    crawlLinks: true
  }
}

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

No branches or pull requests

3 participants