Hi, I created a custom Shopify app using webhooks and it was hosted using Render. I’m experimenting with changing the hosting server to use Google Cloud Run instead.
I have set up the server on Google Cloud Run and verified the server is running when hitting endpoints on postman.
I updated the application and redirection URLs to use the new Google Cloud Run URLs. However, when I run the app through Shopify, the webhooks do not get triggered, and I don’t see any logs in the Partner dashboard. They only work with the old Render URLs.
I’ve tried uninstalling/installing after updating the URLs but no luck. I’m using the node Shopify template app with webhook api version 2024-10.
Do you have any idea why this new server wouldn’t trigger the webhooks?
How are the webhooks registered?
If they have been created with the GraphQL API you will need to run a update mutation to change the endpoint they are targeted at.
If they have been registered in the TOML file you need to ensure you do a shopify app deploy
. Although I don’t know what your setup is here as this will affect your production app config.
The webhooks are subscribed using the API.
I have this in my index.js, where my app server is set up.
...
// Set up Shopify authentication and webhook handling
app.get(shopify.config.auth.path, shopify.auth.begin());
app.get(
shopify.config.auth.callbackPath,
shopify.auth.callback(),
shopify.redirectToShopifyOrAppRoot()
);
app.post(
shopify.config.webhooks.path,
shopify.processWebhooks({ webhookHandlers: WebhookHandlers })
);
// If you are adding routes outside of the /api path, remember to
// also add a proxy rule for them in web/frontend/vite.config.js
app.use("/api/*", shopify.validateAuthenticatedSession());
...
Then it calls the these webhooks from WebhookHandlers
/**
* @type {{[key: string]: import("@shopify/shopify-api").WebhookHandler}}
*/
export default {
ORDERS_CREATE: {
deliveryMethod: DeliveryMethod.Http,
callbackUrl: "/api/webhooks",
callback: async (topic, shop, body) => {
const payload = await JSON.parse(body);
await mapShopifyToHubspot(payload, "created");
},
},
ORDERS_UPDATED: {
deliveryMethod: DeliveryMethod.Http,
callbackUrl: "/api/webhooks",
callback: async (topic, shop, body) => {
const payload = await JSON.parse(body);
await mapShopifyToHubspot(payload, "updated");
},
},
};
All I have in my shopify.app.toml for webhooks is the api version. I have tried shopify app deploy
after updating the application URLs but that didn’t work.
So I don’t know if this automatically updates, you’d need to check the documentation for the template you are using.
However, what you can do is check your existing webhooks.
If you query one of the stores with the app installed, you can see the webhooks webhookSubscriptions - GraphQL Admin
You can/may need to manually update the webhooks which you can do using the mutation webhookSubscriptionUpdate - GraphQL Admin
I’m still new to using containers and deploying images on Cloud Run, so I had to push up an new image after updating application URLs and deploying.
This worked for my development store but did not work on a production store I had the app installed on.
I added the webhook subscriptions to TOML file and that worked. I’m assuming the webhook subscriptions were storing/referencing the old endpoint URLs, and the webhook subscriptions from the TOML overridden subscriptions through API/HTTPS.