mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
71dbb45ca8
* fix(pages): pin revalidate loopback origin * test(pages): cover production revalidation origin * fix(pages): preserve internal revalidation boundaries * fix(pages): preserve on-demand revalidation boundaries * fix(pages): dispatch Worker revalidation internally * fix(pages): authenticate revalidation request context * fix(pages): isolate revalidation transport headers * test(pages): account for generated route table size * fix(pages): align on-demand revalidation semantics * fix(pages): align revalidation response cache parity * fix(pages): preserve regenerated ISR representations * fix(pages): align ISR cache representations * fix(pages): preserve canonical ISR representations * fix(pages): align cached response parity * fix(pages): preserve custom App render props * fix(pages): preserve optional App page props * fix(pages): preserve optional App props on the client * fix(pages): normalize client App page props * fix(pages): preserve App data merge semantics * fix(pages): keep redirect status helper internal * fix(pages): match Next.js terminal ISR behavior * fix(pages): preserve custom app error envelopes * fix(pages): match Next.js dev revalidation semantics * test(pages): align dev revalidation parity coverage * chore(pages): remove stale cache helper exports * fix(cache): preserve explicit no-store context
47 lines
1.8 KiB
TypeScript
47 lines
1.8 KiB
TypeScript
import {
|
|
getRevalidateParityState,
|
|
incrementRevalidateParityGenerationCount,
|
|
} from "../revalidate-parity-state";
|
|
|
|
export default function RevalidateParityTarget({ renderedAt }: { renderedAt: number }) {
|
|
return <p id="rendered-at">rendered at: {renderedAt}</p>;
|
|
}
|
|
|
|
export async function getStaticProps() {
|
|
incrementRevalidateParityGenerationCount();
|
|
const { mode, revalidate } = getRevalidateParityState();
|
|
const withRevalidate = <T extends Record<string, unknown>>(result: T) =>
|
|
revalidate === undefined ? result : { ...result, revalidate };
|
|
await new Promise((resolve) => setTimeout(resolve, mode === "concurrent" ? 300 : 50));
|
|
if (mode === "error") throw new Error("intentional revalidation failure");
|
|
if (mode === "notFound") return withRevalidate({ notFound: true });
|
|
if (mode === "redirect") {
|
|
return withRevalidate({ redirect: { destination: "/about", permanent: false } });
|
|
}
|
|
if (mode === "permanentRedirect") {
|
|
return withRevalidate({ redirect: { destination: "/about", permanent: true } });
|
|
}
|
|
if (mode === "basePathFalseRedirect") {
|
|
return withRevalidate({
|
|
redirect: { destination: "/about", permanent: false, basePath: false },
|
|
});
|
|
}
|
|
if (mode === "conflictingRedirect") {
|
|
return withRevalidate({
|
|
redirect: { destination: "/about", permanent: true, statusCode: 308 },
|
|
});
|
|
}
|
|
if (mode === "invalidStatusRedirect") {
|
|
return withRevalidate({ redirect: { destination: "/about", statusCode: 304 } });
|
|
}
|
|
if (mode === "externalRedirect") {
|
|
return withRevalidate({
|
|
redirect: { destination: "https://example.com/revalidated", permanent: false },
|
|
});
|
|
}
|
|
if (mode === "promised") {
|
|
return withRevalidate({ props: Promise.resolve({ renderedAt: Date.now() }) });
|
|
}
|
|
return withRevalidate({ props: { renderedAt: Date.now() } });
|
|
}
|