From 0682dd0e2ff06061c6bd5a4dce01ca52b2d59a2f Mon Sep 17 00:00:00 2001 From: Denozordec Date: Mon, 29 Jun 2026 15:32:18 +0700 Subject: [PATCH] =?UTF-8?q?fix(web):=20=D0=BD=D0=B5=20=D0=BE=D1=82=D0=BF?= =?UTF-8?q?=D1=80=D0=B0=D0=B2=D0=BB=D1=8F=D1=82=D1=8C=20Content-Type=20?= =?UTF-8?q?=D0=BD=D0=B0=20DELETE=20=D0=B1=D0=B5=D0=B7=20=D1=82=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- apps/web/src/lib/api-client.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/web/src/lib/api-client.ts b/apps/web/src/lib/api-client.ts index 8c4d3f0..30fd16d 100644 --- a/apps/web/src/lib/api-client.ts +++ b/apps/web/src/lib/api-client.ts @@ -22,18 +22,24 @@ export class ApiError extends Error { async function fetchApi(path: string, options: RequestInit = {}): Promise { const url = `${API_BASE}${path.startsWith('/') ? path : `/${path}`}` + const headers = new Headers(options.headers) + if (options.body != null && !headers.has('Content-Type')) { + headers.set('Content-Type', 'application/json') + } const res = await fetch(url, { - headers: { 'Content-Type': 'application/json', ...options.headers }, ...options, + headers, }) if (!res.ok) { let message = res.statusText || 'API error' try { const data = (await res.json()) as { error?: string | { message?: string; code?: string } + message?: string } if (typeof data?.error === 'string') message = data.error else if (data?.error?.message) message = data.error.message + else if (typeof data?.message === 'string') message = data.message } catch { /* ignore */ }