diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index a656413..c25d7e3 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -21,16 +21,17 @@ export async function apiFetch(path: string, options: RequestOptions = {}) { } } + const isFormData = body instanceof FormData + const contentTypeHeader = isFormData ? {} : { 'Content-Type': 'application/json' } + const response = await fetch(buildUrl(path), { ...rest, headers: { - 'Content-Type': 'application/json', + ...contentTypeHeader, ...authHeader, ...headers, }, - body: body !== undefined && body !== null && !(body instanceof FormData) - ? JSON.stringify(body) - : body, + body: isFormData ? body : (body !== undefined && body !== null ? JSON.stringify(body) : undefined), }) const text = await response.text()