feat: use Next.js on demand revalidation

This commit is contained in:
swve 2023-05-19 09:33:54 +00:00
parent 86e4ec64b5
commit cc6cc52ba5
7 changed files with 39 additions and 10 deletions

View file

@ -0,0 +1,19 @@
import { NextRequest, NextResponse } from "next/server";
import { revalidateTag } from "next/cache";
export async function GET(request: NextRequest) {
const tag: any = request.nextUrl.searchParams.get("tag");
revalidateTag(tag);
return NextResponse.json(
{ revalidated: true, now: Date.now() },
{
status: 200,
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
},
}
);
}