App reviews, troubleshooting, and recommendations
Hello,
I'm using the latest remix template and registered an orders/create webhook. On Vercel I'm getting with this code many 422 errors. These 422 don't even get send to the webhook destination. It seems like there is something wrong and the error occurs before sending.
Does anyone has the same problem?
Here is my code:
webhooks.jsx
import { authenticate } from "../shopify.server"; import db from "../db.server"; export const action = async ({ request }) => { const { topic, shop, session, admin, payload } = await authenticate.webhook(request); if (!admin) { // The admin context isn't returned if the webhook fired after a shop was uninstalled. throw new Response(); } switch (topic) { case "APP_UNINSTALLED": if (session) { await db.session.deleteMany({ where: { shop } }); } break; case "ORDERS_CREATE": if (session) { console.log(payload); const webhook = new admin.rest.resources.Webhook({session: session}); webhook.topic = "orders/create"; webhook.address = "URL"; webhook.format = "json"; webhook.save({ update: true, }); } break; case "CUSTOMERS_DATA_REQUEST": case "CUSTOMERS_REDACT": case "SHOP_REDACT": default: throw new Response("Unhandled webhook topic", { status: 404 }); } throw new Response(); };
Part of the shopify.server.js code
webhooks: { APP_UNINSTALLED: { deliveryMethod: DeliveryMethod.Http, callbackUrl: "/webhooks", }, ORDERS_CREATE: { deliveryMethod: DeliveryMethod.Http, callbackUrl: "/webhooks", }, },
Would be awesome if someone knows the answer!
Best regards
Lukas
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024