From b8f54f9871fa897b68a16246123d9234f0421fdd Mon Sep 17 00:00:00 2001 From: Macbook Date: Sun, 7 Dec 2025 20:55:17 +0300 Subject: [PATCH] fix https error --- api/static/js/api.js | 7 +++++-- api/static/js/cookies.js | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/static/js/api.js b/api/static/js/api.js index e47cd0f..0cabd47 100644 --- a/api/static/js/api.js +++ b/api/static/js/api.js @@ -1,7 +1,9 @@ // api.js export async function apiRequest(url, payload = {}, method = 'POST') { - const res = await fetch(url, { - method: method, + const finalUrl = new URL(url, window.location.origin).toString(); + + const res = await fetch(finalUrl, { + method, headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' @@ -14,5 +16,6 @@ export async function apiRequest(url, payload = {}, method = 'POST') { const text = await res.text(); throw new Error(`HTTP ${res.status}: ${text}`); } + return res.json(); } \ No newline at end of file diff --git a/api/static/js/cookies.js b/api/static/js/cookies.js index b5dd2f2..f335f1a 100644 --- a/api/static/js/cookies.js +++ b/api/static/js/cookies.js @@ -23,7 +23,7 @@ export async function setCookie(name, value, days = 180) { } } - const secure = false; // TODO включить после тестов + const secure = true; // TODO включить после тестов const sameSite = 'Lax'; const expires = new Date(Date.now() + days * 864e5).toUTCString();