mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 14:06:59 +00:00
Remove background revalidate, improve response/request name
This commit is contained in:
parent
8cd95842c7
commit
4e517256e5
@ -51,9 +51,6 @@ export default async function Page({ params }: { params: { slug: string[]; local
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Background revalidate once every day.
|
|
||||||
// export const revalidate = 86400;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get paths for each page.
|
* Get paths for each page.
|
||||||
*/
|
*/
|
||||||
|
@ -7,14 +7,14 @@ const SANITY_WEBHOOK_SECRET = `${process.env.SANITY_WEBHOOK_SECRET}`;
|
|||||||
|
|
||||||
export async function POST(request: NextRequest) {
|
export async function POST(request: NextRequest) {
|
||||||
// Await the response from our request.
|
// Await the response from our request.
|
||||||
const response = await request.json();
|
const requestData = await request.json();
|
||||||
|
|
||||||
// Get headers.
|
// Get headers.
|
||||||
const headersList = headers();
|
const headersList = headers();
|
||||||
|
|
||||||
// Get Sanity webhook signature header name.
|
// Get Sanity webhook signature header name.
|
||||||
const signature = `${headersList.get(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.
|
// Log out validity of request.
|
||||||
console.log(`===== Is the webhook request valid? ${isValid}`);
|
console.log(`===== Is the webhook request valid? ${isValid}`);
|
||||||
@ -25,9 +25,9 @@ export async function POST(request: NextRequest) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const slug = response.slug;
|
const slug = requestData.slug;
|
||||||
const locale = response.locale;
|
const locale = requestData.locale;
|
||||||
const type = response.type;
|
const type = requestData.type;
|
||||||
let pathToRevalidate = "";
|
let pathToRevalidate = "";
|
||||||
|
|
||||||
if (type === "home") {
|
if (type === "home") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user