fix https error
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
// api.js
|
// api.js
|
||||||
export async function apiRequest(url, payload = {}, method = 'POST') {
|
export async function apiRequest(url, payload = {}, method = 'POST') {
|
||||||
const res = await fetch(url, {
|
const finalUrl = new URL(url, window.location.origin).toString();
|
||||||
method: method,
|
|
||||||
|
const res = await fetch(finalUrl, {
|
||||||
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Accept': 'application/json'
|
'Accept': 'application/json'
|
||||||
@@ -14,5 +16,6 @@ export async function apiRequest(url, payload = {}, method = 'POST') {
|
|||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
throw new Error(`HTTP ${res.status}: ${text}`);
|
throw new Error(`HTTP ${res.status}: ${text}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ export async function setCookie(name, value, days = 180) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const secure = false; // TODO включить после тестов
|
const secure = true; // TODO включить после тестов
|
||||||
const sameSite = 'Lax';
|
const sameSite = 'Lax';
|
||||||
|
|
||||||
const expires = new Date(Date.now() + days * 864e5).toUTCString();
|
const expires = new Date(Date.now() + days * 864e5).toUTCString();
|
||||||
|
|||||||
Reference in New Issue
Block a user