NuxtN
Nuxt2y ago
13 replies
Yutako

Cloudflare Pages - Cached Subrequest / SSR fetch

Hey there, im using Nuxt in a Cloudflare pages runtime.

Using
useFetch
or useAsyncData on the initial request (SSR) will not do a "real" request, as long the target path is located in server/api routes, correct?
It just calls the defineEventHandler, instead of calling the url like
useFetch
would do it on client-side.

This could be a problem, when you start to cache api responses through e.g. Cloudflare. That's because the fetch on server-side (uncached) and client-side (cached) can receive different states.

Is there any logic/option to force the fetch method to do an "external request" even on server-side?
Was this page helpful?