Files
JJ KasperandGitHub 8f5ffed72e Update fetch cache handling with POST requests (#46856)
This updates to no longer skip caching POST or authed requests with the
fetch cache and instead we bail when `cookies()` or `headers()` is used
prior which is a better heuristic to signal user specific data would be
related to the fetch request.

x-ref: [slack
thread](https://vercel.slack.com/archives/C042LHPJ1NX/p1678130069138849)

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
2023-03-06 21:30:29 -08:00

20 lines
378 B
JavaScript

export const revalidate = 3
export default async function Page() {
const data = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random',
{
headers: {
cookie: 'authorized=true',
},
}
).then((res) => res.text())
return (
<>
<p id="page">/variable-revalidate/cookie</p>
<p id="page-data">{data}</p>
</>
)
}