mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Continues https://github.com/vercel/next.js/pull/91603 applying the encoding normalization further and narrows in a better regression test separate of root params and specific to vary params flag.
23 lines
637 B
TypeScript
23 lines
637 B
TypeScript
import type { NextApiRequest, NextApiResponse } from 'next'
|
|
|
|
export default async function handler(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse<{ revalidated: boolean }>
|
|
) {
|
|
const pathParam = req.query['path']
|
|
|
|
if (!pathParam) {
|
|
return res.status(400).json({ revalidated: false })
|
|
}
|
|
|
|
const paths = Array.isArray(pathParam) ? pathParam : [pathParam]
|
|
|
|
try {
|
|
await Promise.all(paths.map((path) => res.revalidate(path)))
|
|
return res.status(200).json({ revalidated: true })
|
|
} catch (error) {
|
|
console.error('Failed to revalidate paths:', paths, error)
|
|
return res.status(500).json({ revalidated: false })
|
|
}
|
|
}
|