mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
25 lines
591 B
JavaScript
25 lines
591 B
JavaScript
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' } }
|
|
)
|
|
}
|