mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
24 lines
696 B
JavaScript
24 lines
696 B
JavaScript
import { revalidatePath } from 'next/cache'
|
|
import { NextResponse } from 'next/server'
|
|
|
|
const isCacheComponentsEnabled = !!process.env.__NEXT_CACHE_COMPONENTS
|
|
|
|
export async function GET(request) {
|
|
const lang = request.nextUrl.searchParams.get('lang') || 'en'
|
|
const withSlash = request.nextUrl.searchParams.get('withSlash') !== 'false'
|
|
|
|
// With rewrites, we need to revalidate the destination path (the actual
|
|
// page), not the source path that users visit.
|
|
let path = isCacheComponentsEnabled
|
|
? `/${lang}/cache-components`
|
|
: `/${lang}/legacy`
|
|
|
|
if (withSlash) {
|
|
path += '/'
|
|
}
|
|
|
|
revalidatePath(path)
|
|
|
|
return NextResponse.json({ timestamp: new Date().toISOString() })
|
|
}
|