content: Content is not loaded after generate

Environment


  • Operating System: Linux
  • Node Version: v16.15.0
  • Nuxt Version: 3.0.0-rc.4
  • Package Manager: npm@8.5.5
  • Builder: vite
  • User Config: css, build, typescript, modules, components
  • Runtime Modules: @nuxt/content@2.0.1, unplugin-icons/nuxt
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-jdzmbl?file=components/Feed.vue

  1. Open stackblitz
  2. There are generated .output by npm run generate. I don’t know how to execute the generation command in stackblits, so I generated the files locally and put them in the project. You should get the same result by regenerating.
  3. Run npm run preview
  4. On / path you should see valid JSON array with content. But on subpath you should see HTML instead JSON

Describe the bug

I have several pages to display the content. In the desktop, the filtered JSON is displayed correctly on each page. However, after generating the site, HTML is returned instead of JSON

Additional context

No response

Logs

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 16 (9 by maintainers)

Most upvoted comments

Try serving generated files using npx serve ./output/public.

Seems that serving with yarn nuxi preview cause this issue.

@danielroe Do you know what could have caused this issue?

The -s enables fallback to index.html if it doesn’t find an exact match. Maybe there is a bug in serve with query parameters?