mirror of
https://github.com/wasrusgen/zov-tech.git
synced 2026-06-03 19:44:48 +00:00
fix(miniapp): correct backend URL format + drop Content-Type to avoid CORS preflight
This commit is contained in:
parent
4f0c51c453
commit
67dd0eac0c
@ -43,14 +43,18 @@ async function fetchMe() {
|
|||||||
status_until: "12.08.2026",
|
status_until: "12.08.2026",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const res = await fetch(`${BACKEND_URL}/api/me`, {
|
// Apps Script Web App: путь через query-параметр.
|
||||||
|
// Заголовок Content-Type НЕ ставим — иначе браузер шлёт CORS preflight,
|
||||||
|
// который Apps Script не обрабатывает. Без заголовка fetch использует
|
||||||
|
// text/plain — Apps Script всё равно парсит body как JSON.
|
||||||
|
const res = await fetch(`${BACKEND_URL}?path=me`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
initData: tg?.initData || "",
|
initData: tg?.initData || "",
|
||||||
startParam: tg?.initDataUnsafe?.start_param || null,
|
startParam: tg?.initDataUnsafe?.start_param || null,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
if (!res.ok) throw new Error("backend HTTP " + res.status);
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user