fix: skip body and Content-Type for GET/HEAD webhooks

This commit is contained in:
Julien Calixte
2026-03-14 18:32:01 +01:00
parent 8c9ab34565
commit 4e54d51d14

View File

@@ -24,16 +24,17 @@ const fireWebhooks = async (
const webhooks = getWebhooksByDid(did); const webhooks = getWebhooksByDid(did);
if (webhooks.length === 0) return; if (webhooks.length === 0) return;
const results = await Promise.allSettled( const results = await Promise.allSettled(
webhooks.map(({ method, url, token }) => webhooks.map(({ method, url, token }) => {
fetch(url, { const hasBody = method !== "GET" && method !== "HEAD";
return fetch(url, {
method, method,
headers: { headers: {
"Content-Type": "application/json", ...(hasBody ? { "Content-Type": "application/json" } : {}),
...(token ? { Authorization: `Bearer ${token}` } : {}), ...(token ? { Authorization: `Bearer ${token}` } : {}),
}, },
body: JSON.stringify(payload), body: hasBody ? JSON.stringify(payload) : undefined,
}) });
), }),
); );
for (const result of results) { for (const result of results) {
if (result.status === "rejected") { if (result.status === "rejected") {