Configurable API-location

This commit is contained in:
2023-05-25 10:42:19 +02:00
parent e0877add30
commit 1d263ef45a
4 changed files with 48 additions and 15 deletions

View File

@ -1,4 +1,23 @@
const apiUri = "http://localhost:6531";
let apiUri = `http://${window.location.host.split(':')[0]}:6531`
if(getCookie("apiUri") != ""){
apiUri = getCookie("apiUri");
}
function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i < ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
async function GetData(uri){
let request = await fetch(uri, {