-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroute.ts
More file actions
26 lines (22 loc) · 754 Bytes
/
Copy pathroute.ts
File metadata and controls
26 lines (22 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { NextRequest, NextResponse } from "next/server";
import { revalidateTag } from "next/cache";
import { createClient } from "@/prismicio";
export async function POST(request: NextRequest) {
try {
const body = await request.json();
// Verify the webhook secret if you have one
const secret = request.headers.get("repository-name");
if (secret !== "coderchef") {
return NextResponse.json({ message: "Invalid secret" }, { status: 401 });
}
// Revalidate all Prismic content
revalidateTag("prismic");
return NextResponse.json({ revalidated: true, now: Date.now() });
} catch (error) {
console.error("Revalidation error:", error);
return NextResponse.json(
{ message: "Error revalidating" },
{ status: 500 }
);
}
}