Shopify / shopify-app-template-remix

371 stars 149 forks source link

Webhooks are not triggered in deployed App #873

Closed FynnMenkIT closed 2 weeks ago

FynnMenkIT commented 3 weeks ago

... Setup Information in the recent bug and the same setup as the author of #818

Actually I would like to reopen the issue #818 , because of us having the same problem for deployed apps and the recent mentioned bug. The described and only the described way of @vincaslt is working. (Which is a very specific way to setup a working development environment to be honest, but it is working to be fair)

OK, so riding on the back of my observation, I got it to work like this:

  1. npm run dev -- --reset
  2. uninstall the app if installed before
  3. install the app
  4. shopify app deploy in a new console window
  5. hooks are firing (until next start, then repeat the steps again if adding webhooks, or 1 & 4 if not).

Is there a better way that doesn't require juggling URLs?

Unfortunately this is only working when having a locale machine running. We want to deploy our app and the webhooks are not getting triggered.

I was expecting this to be only a problem in the local environment. In addition to this by configurate the webhooks via .toml, there is no way to see the webhooks anymore. (it was possible with the previous integration via webhook registration hook ). The only way to see the registered hooks are:

  1. Trigger them with a console.log or logger: { level: LogSeverity.Debug, httpRequests: true, },
  2. See them in the partner dashboard under the specific deployed app version -> configuration

For our deployed app, we can see them in the partner dashboard, but they are not triggered in the console. Does anyone else has a problem with not being able to trigger the webhooks ?

lizkenyon commented 2 weeks ago

Hi there 👋

I don't believe this is an issue with the Remix template.

I would encourage you to create a post in the .dev community forums. These are forwarded to the teams that own the product area.

ccarlosm commented 2 weeks ago

I’m not sure if this is the case, but I encountered a similar issue that caused me quite a few headaches initially:

When running npm run dev, the app’s URLs in the development environment get updated, which can cause the APP_UNINSTALLED webhook to fire with an outdated URL and fail in development environments.

To work around this and ensure APP_UNINSTALLED is delivered to the correct URL, you can delete the session information in your database. This will trigger the afterAuth hook on the next page reload, updating the URL and successfully delivering APP_UNINSTALLED to the correct endpoint.

In production, however, the app URL should remain constant, and the app should be run with npm run build instead of npm run dev (Shopify documentation), so this problem shouldn’t occur.