Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
Hi!
I have followed all the steps exactly as tutorial says and I cannot register a web hook.
The server.js contains the following code:
server.use(
createShopifyAuth({
apiKey: SHOPIFY_API_KEY,
secret: SHOPIFY_API_SECRET_KEY,
scopes: ['read_products', 'write_products'],
async afterAuth(ctx) {
const { shop, accessToken } = ctx.session;
ctx.cookies.set('shopOrigin', shop, {
httpOnly: false,
secure: true,
sameSite: 'none'
});
const registration = await registerWebhook({
address: `${HOST}/webhooks/products/create`,
topic: 'PRODUCTS_CREATE',
accessToken,
shop,
apiVersion: ApiVersion.October19
});
if (registration.success) {
console.log('Successfully registered webhook!');
} else {
console.log('Failed to register webhook', registration.result);
}
await getSubscriptionUrl(ctx, accessToken, shop);
},
}),
);
During application registration in a store I get this in server console:
Failed to register webhook {
data: {
webhookSubscriptionCreate: { userErrors: [Array], webhookSubscription: null }
},
extensions: {
cost: {
requestedQueryCost: 10,
actualQueryCost: 10,
throttleStatus: [Object]
}
}
}
Is there anything I am doing wrong?
Thanks!
Hey @Jevgeni
Can you provide the request ID response header so we can take a look?
Kevin_A | Solutions Engineer @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog
Hi!
Thank you for your reply! In my case I was using localhost, which is something not designed to work in this case. So now I have migrated the app onto AWS and everything works fine.
Regards,
Jevgeni