user1452030
user1452030

Reputation: 1021

Shopify: There’s no page at this address

I'm having the exact same issue described in this question. But the solution doesn't work for me. The app_uninstalled webhook works perfectly fine and I'm disabling the access token upon deletion and also removing the store from the active shops list. I'm using Shopify CLI and Node.

This is what I'm doing:

I'm seeing a "There’s no page at this address" error.

Code corresponding to webhooks:

    router.post("/webhooks", async (ctx) => {
    try {
      console.log(
        `Getting called successfully. Context object: ${JSON.stringify(ctx)}`
      );
      let topic = ctx.get('x-shopify-topic')
      if(topic && topic === `app/uninstalled`){
          const shop = ctx.get('x-shopify-shop-domain')
          console.warn(`App uninstalled from shop: ${shop}. Removing shop from active shopify shops list`)
          delete ACTIVE_SHOPIFY_SHOPS[shop]
          console.debug(`App uninstalled from shop: ${shop}. Successfully removed shop from active shopify shops list. Current list is: ${JSON.stringify(ACTIVE_SHOPIFY_SHOPS)}`)
          console.warn(`App uninstalled from shop: ${shop}. Attempting to mark token as disabled...`)
          const record = await getShopToken(shop, true)
          console.debug(`Token record from DB for ${shop}: ${JSON.stringify(record)}`)
          if(record){
            await storeShopToken(record.SHOP, record.ACCESS_TOKEN, record.SCOPE, `DISABLED`)
            console.debug(`Successfully disabled access token for ${shop}.`)
          }else{
            console.warn(`Could not find the current token entry for ${shop}. Unable to mark token as disabled.`)
          }
      }
      await Shopify.Webhooks.Registry.process(ctx.req, ctx.res);
      console.log(`Webhook processed, returned status code 200`);
    } catch (error) {
      console.log(`Failed to process webhook: ${error}`);
    }
  });

This is preventing the app from getting certified. Please advise.

Upvotes: 2

Views: 845

Answers (1)

aarkerio
aarkerio

Reputation: 2354

If you are finding this message only on the reinstalling app cases, you need to delete the shop.shopify_token and the shop.shopify_domain fields after you receive the uninstall webhook.

What I did was to create a new uninstalled_domain column, passed the value of shop.shopify_domain to that new column after receiving the uninstall WH and then I deleted the shop.shopify_domain column.

When a user logins, I check if uninstalled_domain exists, if so, it means the user is not new, but reinstalling. Then I switch to that row in the DB and delete the just created row.

That way the user finds all his data after reinstalling.

Upvotes: 1

Related Questions