I use nuxt3 with nuxtcontent. My blog posts are rendered perfectly on localhost and locally when I use nuxt build
. However, as soon as I deploy it to production, the blog posts can't be found.
Error message:
<!doctype html>
<html lang="en">
<head>
<title>Not Found</title>
</head>
<body>
<h1>Not Found</h1><p>The requested resource was not found on this server.</p>
</body>
</html>
My nuxt config:
export default defineNuxtConfig({
ssr: false,
target: 'static',
modules: ['@nuxt/content'],
content: {
markdown: {
toc: { depth: 3, searchDepth: 3 }
}
},
nitro: {
prerender: {
routes: ['/sitemap.xml']
}
}
})
My package json versions:
{
"private": true,
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview"
},
"devDependencies": {
"@nuxt/content": "2.6.0",
"@vueuse/nuxt": "^9.12.0",
"autoprefixer": "^10.4.7",
"consola": "^3.2.2",
"nuxt": "^3.6.1",
"postcss": "^8.4.21",
"sitemap": "^7.1.1"
},
"dependencies": {
"@pinia-plugin-persistedstate/nuxt": "^1.0.0",
"@pinia/nuxt": "^0.4.1",
"@tailwindcss/line-clamp": "^0.4.0",
"@vueuse/core": "^9.12.0",
"pinia": "^2.0.30",
"pinia-plugin-persistedstate": "^3.0.2",
"tailwindcss": "^3.2.6",
"vue": "^3.2.47",
}
Edit:
I have changed the routes for nuxt content to prerender:
routeRules: {
'/**': { prerender: true },
'/dashboard/**': { ssr: false },
}
However, now production only retrieves the nuxt content documents on refresh and not on initial load. I tried both using nuxt generate and nuxt build.