Using Next.js SSG and prefetching, I am seeing that all of my prefetch requests fail with a 412. Using the XDN devtools, I can see the request and the route it was matched with:
My router is configured with edge caching as follows:
import { Router } from '@xdn/core/router';
import { nextRoutes } from '@xdn/next';
// import getPrerenderRequests from './xdn/getPrerenderRequests';
const SSR_CACHE_CONFIG = {
browser: {
maxAgeSeconds: 0,
},
edge: {
maxAgeSeconds: 60 * 60 * 24,
staleWhileRevalidateSeconds: 60 * 60 * 24,
},
};
const API_CACHE_CONFIG = {
browser: {
maxAgeSeconds: 0,
serviceWorkerSeconds: 60 * 60 * 24,
},
edge: {
maxAgeSeconds: 60 * 60 * 24,
staleWhileRevalidateSeconds: 60 * 60 * 24,
},
};
export default new Router()
// .prerender(getPrerenderRequests)
.get('/category/:name', ({ cache }) => cache(SSR_CACHE_CONFIG))
.get('/product/:id', ({ cache }) => cache(SSR_CACHE_CONFIG))
.get('/_next/data/:build/category/:name.json', ({ cache }) =>
cache(API_CACHE_CONFIG)
)
.get('/_next/data/:build/product/:id.json', ({ cache }) =>
cache(API_CACHE_CONFIG)
)
.match('/service-worker.js', ({ serviceWorker }) => {
return serviceWorker('.next/static/service-worker.js');
})
.use(nextRoutes); // automatically adds routes for all files under /pages
I did try to make the same request while removing the xdn_prefetch=1
param and see that I get a valid response. Is this something misconfigured in my router that would always reject these requests?