Remove background revalidate, improve response/request name

This commit is contained in:
Henrik Larsson
2023-07-03 14:38:24 +02:00
parent 8cd95842c7
commit 4e517256e5
2 changed files with 5 additions and 8 deletions

View File

@@ -7,14 +7,14 @@ const SANITY_WEBHOOK_SECRET = `${process.env.SANITY_WEBHOOK_SECRET}`;
export async function POST(request: NextRequest) {
// Await the response from our request.
const response = await request.json();
const requestData = await request.json();
// Get headers.
const headersList = headers();
// Get Sanity webhook signature header name.
const signature = `${headersList.get(SIGNATURE_HEADER_NAME)}`;
const isValid = isValidSignature(JSON.stringify(response), signature, SANITY_WEBHOOK_SECRET);
const isValid = isValidSignature(JSON.stringify(requestData), signature, SANITY_WEBHOOK_SECRET);
// Log out validity of request.
console.log(`===== Is the webhook request valid? ${isValid}`);
@@ -25,9 +25,9 @@ export async function POST(request: NextRequest) {
return;
}
const slug = response.slug;
const locale = response.locale;
const type = response.type;
const slug = requestData.slug;
const locale = requestData.locale;
const type = requestData.type;
let pathToRevalidate = "";
if (type === "home") {