N
Nuxt2y ago
mahnouel

Nuxt 3 SSR Output still refetches content, even though `fetchAsyncData` is used

I've tried
const { data } = await useAsyncData(
'static',
async () =>
await getItems({
collection: 'staticpages',
})
);
const { data } = await useAsyncData(
'static',
async () =>
await getItems({
collection: 'staticpages',
})
);
(uses nuxt-directus) and
const { data: staticpages } = await useFetch(<url>/items/staticpages`);
const { data: staticpages } = await useFetch(<url>/items/staticpages`);
I build via nuxt generate But when I open the generated files on a static server, I see requests to the endpoints when I reload the page / navigate to it. I just can't find out why. I've also tried to use the full-static package, and a lot of other things - but I can't get it to work...
3 Replies
mahnouel
mahnouelOP2y ago
I found out I'm trying to do SSG not SSR
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
mahnouel
mahnouelOP2y ago
I think I found the reason. Nitro tried to be helpful by changing it's behaviour when deployed to Vercel. I've added following route rules, and now it seems to do full SSG:
export default defineNuxtConfig({
...
routeRules: {
'/': { prerender: true },
'/**': { prerender: true },
},
})
export default defineNuxtConfig({
...
routeRules: {
'/': { prerender: true },
'/**': { prerender: true },
},
})
What a headache ^^ Solution found here: https://vercel.com/blog/nuxt-on-vercel#static-and-isr-support-for-nuxt https://github.com/danielroe/nuxt-vercel-isr
Want results from more Discord servers?
Add your server