Files
JJ KasperandGitHub 925fd916ef Fix fallback: true cache-control (#80865)
This ensures we don't treat cache hits for lazily generated `fallback:
true` routes as the fallback itself which has a different cache-control
header than cache hits should.

Fixes: https://github.com/vercel/next.js/issues/80838
2025-06-24 13:46:20 -07:00

41 lines
826 B
JavaScript

import Link from 'next/link'
import { useRouter } from 'next/router'
export async function getStaticPaths() {
return {
paths: ['/fallback-true/first'],
fallback: true,
}
}
export async function getStaticProps({ params }) {
return {
props: {
params,
hello: 'world',
post: params.slug,
random: Math.random(),
time: (await import('perf_hooks')).performance.now(),
},
revalidate: 2,
}
}
export default ({ post, time, params }) => {
if (useRouter().isFallback) {
return <p>hi fallback</p>
}
return (
<>
<p>Post: {post}</p>
<span>time: {time}</span>
<div id="params">{JSON.stringify(params)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/" id="home">
to home
</Link>
</>
)
}