import { NextResponse, NextRequest } from "next/server"; import { revalidatePath } from "next/cache"; import fs from "fs"; import path from "path"; export async function GET(request: NextRequest) { try { const searchParams = request.nextUrl.searchParams; const pathParam = searchParams.get("path") || "/"; const typeParam = (searchParams.get("type") as "page" | "layout") || "layout"; // Revalidate the requested path (defaults to entire app via layout) revalidatePath(pathParam, typeParam); return NextResponse.json({ success: true, revalidatedPath: pathParam, revalidatedType: typeParam, message: `Cache revalidated for ${pathParam} (${typeParam})`, }); } catch (err: any) { return NextResponse.json({ success: false, error: err.message }); } }