For Workers & Pages, what is the name of the domain?
What is the issue or error you’re encountering
I have a Nuxt 3 app using useAsyncData with a pre-rendering approach. The API call is made as follows:
const { data: accommodation, refresh } = await useAsyncData(
accommodations/${locale.value}/${route?.params?.id}, async () => { const payload = { id: route.params.id, check_in: searchStore.getCheckIn, check_out: searchStore.getCheckOut, adults: searchStore.searchedGuests.adults, children: searchStore.searchedGuests.children, }; const accommodations = await getLodging(payload); return accommodations.data; }); The pages follow a structure like: 👉 http://localhost:3000/en/accommodations/villa-peroni I also have the following Nitro configuration: export default defineNuxtConfig({ ssr: true, devtools: { enabled: true }, experimental: { payloadExtraction: false // Ensures API data is inside index.html }, hooks: { 'nitro:config': async (nitroConfig) => { const accommodations = await getAllAccommodationSlugs(); if (!accommodations || !Array.isArray(accommodations)) { console.error('Error: accommodations is undefined or not an array'); return; } nitroConfig.prerender = nitroConfig.prerender || {}; nitroConfig.prerender.routes = nitroConfig.prerender.routes || []; nitroConfig.prerender.routes.push(...['/en', '/nl', ...accommodations.map(slug =>
/en/accommodations/${slug})]); nitroConfig.routeRules = nitroConfig.routeRules || {}; // ✅ Enable ISR on all accommodation pages (including newly created ones) nitroConfig.routeRules['/en/accommodations/**'] = { headers: { 'Cache-Control': 's-maxage=60, stale-while-revalidate=60', // Cache for 1 hour, refresh in background } }; nitroConfig.routeRules['/nl/accommodations/**'] = { headers: { 'Cache-Control': 's-maxage=60, stale-while-revalidate=60', } }; }, }, router: { options: { strict: false, trailingSlash: false }, }, nitro: { prerender: { crawlLinks: true, failOnError: false, routes: ['/', '/en', '/nl'], }, routeRules: { '/en/accommodations/**': { swr: true }, }, }, }); The Issue After running yarn generate, the pre-rendered routes on Cloudflare are not fetching fresh API data. Instead, they serve stale data from the pre-rendered version. However, on my local server, it fetches fresh data correctly. I also checked the response headers using this command: curl -I https://nice2stay.com/en/accommodations/villa-peroni HTTP/2 308 date: Sat, 22 Mar 2025 09:14:56 GMT location: /en/accommodations/villa-peroni/ access-control-allow-origin: * cache-control: s-maxage=60, stale-while-revalidate=60 strict-transport-security: max-age=31536000; includeSubDomains referrer-policy: strict-origin-when-cross-origin x-content-type-options: nosniff x-frame-options: DENY x-xss-protection: 1; mode=block cf-cache-status: DYNAMIC server: cloudflare cf-ray: 924494e51df3e8cb-HKG
What steps have you taken to resolve the issue?
Cloudflare Page Rules