Unable to register web hook based on Shopify tutorial

Jevgeni
New Member
3 0 0

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!

0 Likes
Kevin_A
Shopify Staff
Shopify Staff
311 42 54

Hey @Jevgeni 

Can you provide the request ID response header so we can take a look?

Kevin_A | Developer Support @ 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

0 Likes
Jevgeni
New Member
3 0 0

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

0 Likes