Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chg(safeFetch): prevent draining body, and passing content-type on head request (#2745)

teob4e4581097a4
diff --git a/js/app/packages/core/util/safeFetch.ts b/js/app/packages/core/util/safeFetch.ts
index c06e74915d..1707484416 100644
--- a/js/app/packages/core/util/safeFetch.ts
+++ b/js/app/packages/core/util/safeFetch.ts
@@ -175,6 +175,7 @@ export async function safeFetch<
...fetchInit,
headers: {
...(fetchInit?.method !== 'GET' &&
+ fetchInit?.method !== 'HEAD' &&
!(fetchInit?.body instanceof FormData) && {
'Content-Type':
(fetchInit?.headers as Record<string, string> | undefined)?.[
@@ -207,6 +208,8 @@ export async function safeFetch<
return err('HTTP_ERROR', `HTTP error! status: ${response.status}`);
}
} else {
+ if (fetchInit.method === 'HEAD') return ok({} as T);
+
const contentType = response.headers.get('Content-Type');
if (!contentType) return ok({} as T);