mirror of
https://github.com/vercel/commerce.git
synced 2025-05-13 05:07:51 +00:00
feat: configure with webhook
Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
This commit is contained in:
parent
6ddcbea8e8
commit
c53986e926
@ -28,4 +28,4 @@ export const TAGS = {
|
|||||||
|
|
||||||
export const HIDDEN_PRODUCT_TAG = 'nextjs-frontend-hidden';
|
export const HIDDEN_PRODUCT_TAG = 'nextjs-frontend-hidden';
|
||||||
export const DEFAULT_OPTION = 'Default Title';
|
export const DEFAULT_OPTION = 'Default Title';
|
||||||
export const SHOPIFY_GRAPHQL_API_ENDPOINT = '/api/2023-01/graphql.json';
|
export const SHOPIFY_GRAPHQL_API_ENDPOINT = '/api/2023-04/graphql.json';
|
||||||
|
@ -419,11 +419,14 @@ export async function getProducts({
|
|||||||
|
|
||||||
// This is called from `app/api/revalidate.ts` so providers can control revalidation logic.
|
// This is called from `app/api/revalidate.ts` so providers can control revalidation logic.
|
||||||
export async function revalidate(req: NextRequest): Promise<NextResponse> {
|
export async function revalidate(req: NextRequest): Promise<NextResponse> {
|
||||||
|
console.log(`Receiving revalidation request from Shopify.`);
|
||||||
// We always need to respond with a 200 status code to Shopify,
|
// We always need to respond with a 200 status code to Shopify,
|
||||||
// otherwise it will continue to retry the request.
|
// otherwise it will continue to retry the request.
|
||||||
const collectionWebhooks = ['collections/create', 'collections/delete', 'collections/update'];
|
const collectionWebhooks = ['collections/create', 'collections/delete', 'collections/update'];
|
||||||
const productWebhooks = ['products/create', 'products/delete', 'products/update'];
|
const productWebhooks = ['products/create', 'products/delete', 'products/update'];
|
||||||
const topic = headers().get('x-shopify-topic') || 'unknown';
|
const topic = headers().get('x-shopify-topic') || 'unknown';
|
||||||
|
console.log(`Receiving revalidation request with topic.`, { topic });
|
||||||
|
|
||||||
const secret = req.nextUrl.searchParams.get('secret');
|
const secret = req.nextUrl.searchParams.get('secret');
|
||||||
const isCollectionUpdate = collectionWebhooks.includes(topic);
|
const isCollectionUpdate = collectionWebhooks.includes(topic);
|
||||||
const isProductUpdate = productWebhooks.includes(topic);
|
const isProductUpdate = productWebhooks.includes(topic);
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
logging: {
|
||||||
|
fetches: {
|
||||||
|
fullUrl: true
|
||||||
|
}
|
||||||
|
},
|
||||||
eslint: {
|
eslint: {
|
||||||
// Disabling on production builds because we're running checks on PRs via GitHub Actions.
|
// Disabling on production builds because we're running checks on PRs via GitHub Actions.
|
||||||
ignoreDuringBuilds: true
|
ignoreDuringBuilds: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user