fix: skip body and Content-Type for GET/HEAD webhooks
This commit is contained in:
13
jetstream.ts
13
jetstream.ts
@@ -24,16 +24,17 @@ const fireWebhooks = async (
|
||||
const webhooks = getWebhooksByDid(did);
|
||||
if (webhooks.length === 0) return;
|
||||
const results = await Promise.allSettled(
|
||||
webhooks.map(({ method, url, token }) =>
|
||||
fetch(url, {
|
||||
webhooks.map(({ method, url, token }) => {
|
||||
const hasBody = method !== "GET" && method !== "HEAD";
|
||||
return fetch(url, {
|
||||
method,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...(hasBody ? { "Content-Type": "application/json" } : {}),
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
),
|
||||
body: hasBody ? JSON.stringify(payload) : undefined,
|
||||
});
|
||||
}),
|
||||
);
|
||||
for (const result of results) {
|
||||
if (result.status === "rejected") {
|
||||
|
||||
Reference in New Issue
Block a user