Skip to content

Commit

Permalink
Clean up revalidate route
Browse files Browse the repository at this point in the history
  • Loading branch information
Ru Chern Chong committed Jul 27, 2024
1 parent 9428f9c commit 541667c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/api/revalidate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() });
}
};

0 comments on commit 541667c

Please sign in to comment.