mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Reverts vercel/next.js#58484 The correct way to address this is to use the `fetchCache` segment: https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#fetchcache There are valid use-cases to want to force a dynamic response but still need fetch caching. Additionally, this PR updates the docs, since they're incorrect about behavior. [slack x-ref](https://vercel.slack.com/archives/C042LHPJ1NX/p1691623048477119?thread_ts=1691613915.257239&cid=C042LHPJ1NX)
17 lines
469 B
TypeScript
17 lines
469 B
TypeScript
import { NextRequest, NextResponse } from 'next/server'
|
|
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
const delay = 3000
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const start = Date.now()
|
|
const data = await fetch(
|
|
`https://next-data-api-endpoint.vercel.app/api/delay?delay=${delay}`,
|
|
{ next: { revalidate: 3 } }
|
|
).then((res) => res.json())
|
|
const fetchDuration = Date.now() - start
|
|
|
|
return NextResponse.json({ fetchDuration, data, now: Date.now() })
|
|
}
|