Hi,
I’m encountering an issue with the shop/redact
mandatory webhook. It currently shows a 100% failed delivery rate.
My app does not store any customer data from the shop. It only stores the shop’s name and domain, and even that is deleted immediately when the app receives an app/uninstall
webhook.
Here’s the current code I use to handle mandatory webhooks:
import { authenticate } from "../shopify.server";
import crypto from "crypto";
import { json } from "@remix-run/node";
export const action = async ({ request }) => {
const rawPayload = await request.text();
const { shop, topic } = await authenticate.webhook(request);
console.log(`Received ${topic} webhook from ${shop}`);
const signature = request.headers.get("x-shopify-hmac-sha256");
const expectedSignature = crypto
.createHmac("sha256", process.env.SHOPIFY_API_SECRET || "")
.update(rawPayload)
.digest("base64");
if (signature !== expectedSignature) {
console.error("Invalid webhook signature");
return json({ message: "Invalid signature" }, { status: 401 });
}
return json({ success: true });
};
export const loader = () => new Response(null, { status: 405 });
It used to work fine — the app successfully received and responded to the shop/redact
webhook — but starting last week, the delivery show failing.
I believe I’m handling the webhook correctly and returning a 200 OK
response, which is all that should be required if the app doesn’t store any customer data.
Could you help me understand what might be causing the failed deliveries?
Thanks in advance!