diff --git a/web/src/services/api.ts b/web/src/services/api.ts index da200b3..359b009 100644 --- a/web/src/services/api.ts +++ b/web/src/services/api.ts @@ -6,10 +6,11 @@ function authHeaders(): Record { } export async function api(url: string, options: RequestInit = {}): Promise { + const hasBody = options.body !== undefined && options.body !== null; const response = await fetch(url, { ...options, headers: { - ...(options.body instanceof FormData ? {} : { "Content-Type": "application/json" }), + ...(hasBody && !(options.body instanceof FormData) ? { "Content-Type": "application/json" } : {}), ...authHeaders(), ...((options.headers as Record | undefined) ?? {}) } as HeadersInit @@ -20,4 +21,3 @@ export async function api(url: string, options: RequestInit = {}): Promise } return data as T; } -