From 541667c7656e66a6a9065fdc6913017c3ede9286 Mon Sep 17 00:00:00 2001 From: Ru Chern Chong Date: Sun, 28 Jul 2024 03:22:08 +0800 Subject: [PATCH] Clean up revalidate route --- app/api/revalidate/route.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/api/revalidate/route.ts b/app/api/revalidate/route.ts index 62e7fd7..67fd5ce 100644 --- a/app/api/revalidate/route.ts +++ b/app/api/revalidate/route.ts @@ -3,12 +3,13 @@ import { revalidateTag } from "next/cache"; export const GET = (req: NextRequest) => { const secret = req.nextUrl.searchParams.get("secret"); - const tags = req.nextUrl.searchParams.get("tags") as string; - if (secret !== process.env.NEXT_PUBLIC_REVALIDATE_TOKEN) { return NextResponse.json({ message: "Invalid token!" }, { status: 401 }); } - revalidateTag(tags); - return NextResponse.json({ revalidated: true, now: Date.now() }); + const tags = req.nextUrl.searchParams.get("tags"); + if (tags) { + revalidateTag(tags); + return NextResponse.json({ revalidated: true, now: Date.now() }); + } };