next.js/test/e2e/app-dir/ppr-full/app/api/revalidate/route.js
route.js25 lines591 B
import { revalidatePath } from 'next/cache'

export async function GET(request) {
  const url = new URL(request.url)
  const pathnames = url.searchParams.getAll('pathname')
  if (pathnames.length === 0) {
    return new Response(null, { status: 400 })
  }
  for (const pathname of pathnames) {
    let type
    if (pathname.includes('[') && pathname.includes(']')) {
      type = 'page'
    }

    revalidatePath(pathname, type)
  }

  return new Response(
    JSON.stringify({
      revalidated: pathnames,
    }),
    { status: 200, headers: { 'Content-Type': 'application/json' } }
  )
}
Quest for Codev2.0.0
/
SIGN IN