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);
|
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") {
|
||||||
|
|||||||
Reference in New Issue
Block a user