Files
JJ KasperandGitHub 8c7e4f9bc4 Fix fetchCache config and On-Demand Revalidate handling (#47803)
This ensures we properly honor the `export const fetchCache` config and
also ensures we properly bypass fetch-cache when an On-Demand
Revalidation is occurring.

The `export const dynamic` handling is not changed here as that was
behaving correctly and should not influence fetch cache handling only
whether a page is prerendered fully or treated as SSR.

Fixes: https://github.com/vercel/next.js/issues/47273
x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1679078572123979)
2023-04-01 21:15:13 -07:00

10 lines
285 B
JavaScript

export default async function handler(req, res) {
try {
await res.revalidate(req.query.path)
return res.json({ revalidated: true, now: Date.now() })
} catch (err) {
console.error('Failed to revalidate', req.query, err)
return res.json({ revalidated: false })
}
}