From c773adf05e2c5db61f4d87e6df6c898dbcfb9d58 Mon Sep 17 00:00:00 2001 From: wasrusgen Date: Mon, 18 May 2026 13:35:20 +0300 Subject: [PATCH] =?UTF-8?q?fix:=20Content-Type:=20application/json=20?= =?UTF-8?q?=D0=B2=D0=BE=20=D0=B2=D1=81=D0=B5=D1=85=20fetch-=D1=85=D0=B5?= =?UTF-8?q?=D0=BB=D0=BF=D0=B5=D1=80=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit measurements, assembly, request, me, inbox, proposals — 6 модулей, 6 хелперов (_fetchWithTimeout / apiFetch / _api). Co-Authored-By: Claude Sonnet 4.6 --- miniapp/assets/assembly.js | 2 +- miniapp/assets/inbox.js | 1 + miniapp/assets/me.js | 2 +- miniapp/assets/measurements.js | 2 +- miniapp/assets/proposals.js | 1 + miniapp/assets/request.js | 2 +- 6 files changed, 6 insertions(+), 4 deletions(-) diff --git a/miniapp/assets/assembly.js b/miniapp/assets/assembly.js index 94c2e00..d715af1 100644 --- a/miniapp/assets/assembly.js +++ b/miniapp/assets/assembly.js @@ -21,7 +21,7 @@ const Assembly = (function () { const ctrl = new AbortController(); const timer = setTimeout(() => ctrl.abort(), timeoutMs); try { - const res = await fetch(url, { method: "POST", signal: ctrl.signal, body: JSON.stringify(body) }); + const res = await fetch(url, { method: "POST", signal: ctrl.signal, headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); return await res.json(); } catch (e) { if (e.name === "AbortError") throw new Error("Сервер не отвечает — попробуйте ещё раз"); diff --git a/miniapp/assets/inbox.js b/miniapp/assets/inbox.js index fb9f48c..0f57255 100644 --- a/miniapp/assets/inbox.js +++ b/miniapp/assets/inbox.js @@ -24,6 +24,7 @@ const InboxScreen = (function () { try { const res = await fetch(`${BACKEND_URL}/api/${path}`, { method: "POST", signal: ctrl.signal, + headers: { "Content-Type": "application/json" }, body: JSON.stringify({ initData: tg?.initData || "", initDataUnsafe: tg?.initDataUnsafe || null, ...body }), }); return await res.json(); diff --git a/miniapp/assets/me.js b/miniapp/assets/me.js index a6303e7..a010e17 100644 --- a/miniapp/assets/me.js +++ b/miniapp/assets/me.js @@ -15,7 +15,7 @@ const MeScreen = (function () { const ctrl = new AbortController(); const t = setTimeout(() => ctrl.abort(), ms); try { - const res = await fetch(url, { method: "POST", signal: ctrl.signal, body: JSON.stringify(body) }); + const res = await fetch(url, { method: "POST", signal: ctrl.signal, headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); return await res.json(); } catch (e) { if (e.name === "AbortError") throw new Error("Сервер не отвечает"); diff --git a/miniapp/assets/measurements.js b/miniapp/assets/measurements.js index 2f99d70..d41e79e 100644 --- a/miniapp/assets/measurements.js +++ b/miniapp/assets/measurements.js @@ -98,7 +98,7 @@ const Measurements = (function () { const ctrl = new AbortController(); const timer = setTimeout(() => ctrl.abort(), timeoutMs); try { - const res = await fetch(url, { method: "POST", signal: ctrl.signal, body: JSON.stringify(body) }); + const res = await fetch(url, { method: "POST", signal: ctrl.signal, headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); return await res.json(); } catch (e) { if (e.name === "AbortError") throw new Error("Сервер не отвечает — попробуйте ещё раз"); diff --git a/miniapp/assets/proposals.js b/miniapp/assets/proposals.js index b9efa33..8bcfe4e 100644 --- a/miniapp/assets/proposals.js +++ b/miniapp/assets/proposals.js @@ -26,6 +26,7 @@ const Proposals = (function () { const res = await fetch(`${BACKEND_URL}/api/${path}`, { method: "POST", signal: ctrl.signal, + headers: { "Content-Type": "application/json" }, body: JSON.stringify({ ...authBody(), ...extra }), }); if (!res.ok) throw new Error("HTTP " + res.status); diff --git a/miniapp/assets/request.js b/miniapp/assets/request.js index 046d76c..05981df 100644 --- a/miniapp/assets/request.js +++ b/miniapp/assets/request.js @@ -19,7 +19,7 @@ const MeasurementRequest = (function () { const ctrl = new AbortController(); const timer = setTimeout(() => ctrl.abort(), timeoutMs); try { - const res = await fetch(url, { method: "POST", signal: ctrl.signal, body: JSON.stringify(body) }); + const res = await fetch(url, { method: "POST", signal: ctrl.signal, headers: { "Content-Type": "application/json" }, body: JSON.stringify(body) }); return await res.json(); } catch (e) { if (e.name === "AbortError") throw new Error("Сервер не отвечает — попробуйте ещё раз");