mirror of
https://github.com/vercel/commerce.git
synced 2025-04-27 21:37:50 +00:00
24 lines
600 B
TypeScript
24 lines
600 B
TypeScript
import { revalidateTag } from "next/cache";
|
|
import { NextRequest, NextResponse } from "next/server";
|
|
|
|
export const runtime = "edge";
|
|
|
|
export async function POST(req: NextRequest): Promise<NextResponse> {
|
|
try {
|
|
const body = await req.json();
|
|
const tag = body.tag;
|
|
|
|
if (!tag) {
|
|
return NextResponse.json(
|
|
{ message: "Missing tag param" },
|
|
{ status: 400 }
|
|
);
|
|
}
|
|
|
|
revalidateTag(tag);
|
|
return NextResponse.json({ revalidated: true, now: Date.now() });
|
|
} catch (error) {
|
|
return NextResponse.json({ message: "Invalid JSON" }, { status: 400 });
|
|
}
|
|
}
|