Shopify/shopify-app-template-remix

Webhooks is not triggering.

masumluf opened this issue · 3 comments

Yesterday I have created an app using Shopify CLI command. I am trying to print some log whenever anybody uninstall my app. Here is my code below

shopify.app.tomal file
[[webhooks.subscriptions]]
topics = [ "app/uninstalled" ]
uri = "/webhooks/app/uninstalled"

webhooks.app.uninstalled.jsx in the routes folder file

import { authenticate } from "../shopify.server";
import db from "../db.server";

export const action = async ({ request }) => {
  console.log("--- uninstall hook triggered ---");
  const { shop, session, topic } = await authenticate.webhook(request);

  console.log(`Received ${topic} webhook for ${shop}`);

  console.log(shop, session, topic, "shop, session, topic");

  if (session) {
    db.session.deleteMany({ where: { shop } });
  }

  return new Response();
};

Since I am new in shopify app development. I am unable to figure out why this portion of code is not executing while anybody uninstall my app ?Is there anything I have missed ? My

Hey there, have you deployed your app after adding the webhook section to your toml?

Please checked registerd webhook list via api call. please check this example https://shopify.dev/docs/api/admin-rest/2024-01/resources/webhook#get-webhooks

Hey there, have you deployed your app after adding the webhook section to your toml?

Hello not yet, I am running my shopify app locally. I thought new remix routing system will able to receive webhook call but it is not. So I have created a simple node server and use that address and now I can see webhook is triggering.