Files
Zack TannerandGitHub 734fa1df62 fix: ensure route handlers properly track dynamic access (#66446)
In #60645, dynamic access tracking was refactored but we erroneously
stopped tracking dynamic access in route handlers. Request proxying, as
well as tracking segment level configs (such as `export const dynamic =
'force-dynamic'`), were only enabled during static generation. This was
an unintended breaking change that consequently caused dynamic access to
not properly bail from data cache in various circumstances.

This adds some more rigorous testing for route handlers, as this seems
to be a fairly large gap in our fetch cache testing currently.

This PR is easiest to review with [whitespace
disabled](https://github.com/vercel/next.js/pull/66446/files?w=1).
2024-06-01 15:32:50 -07:00

16 lines
349 B
JavaScript

export const dynamic = 'force-dynamic'
export default async function Page() {
const data = await fetch(
'https://next-data-api-endpoint.vercel.app/api/random',
{ cache: 'default' }
).then((res) => res.text())
return (
<>
<p id="page">/force-dynamic-fetch-cache/default-cache</p>
<p id="data">{data}</p>
</>
)
}