decide local / live depending on url

This commit is contained in:
Holly Stubbs 2024-04-26 10:38:46 +01:00
parent cc20ddfd2a
commit aa6ebf12a0
Signed by: tgpholly
GPG Key ID: B8583C4B7D18119E
1 changed files with 4 additions and 3 deletions

View File

@ -258,7 +258,8 @@ kbd {
} }
}, 1000); }, 1000);
fetch(`http://localhost:39194/api/version`, { method: "post" }).then(response => { const versionFetchAddress = window.location.href.replace("127.0.0.1", "localhost").includes("//localhost:") ? "http://localhost:38194/api/version" : "https://multiprobe.eusv.net/api/version";
fetch(versionFetchAddress, { method: "post" }).then(response => {
console.log("hi"); console.log("hi");
response.text().then(versionNumberRaw => { response.text().then(versionNumberRaw => {
const versionNumber = parseInt(versionNumberRaw); const versionNumber = parseInt(versionNumberRaw);
@ -442,7 +443,7 @@ kbd {
function doConnect(apiKey) { function doConnect(apiKey) {
const Buffer = getBufferClass(); const Buffer = getBufferClass();
ws = new WebSocket(window.location.href.includes("//localhost:") ? "ws://localhost:39195" : "wss://ws.eusv.net/t00mp"); ws = new WebSocket(window.location.href.includes("//localhost:") ? "ws://localhost:38195" : "wss://ws.eusv.net/t00mp");
let keepAliveInterval; let keepAliveInterval;
ws.onopen = () => { ws.onopen = () => {
otherCursors.innerHTML = ""; otherCursors.innerHTML = "";
@ -737,7 +738,7 @@ kbd {
doNotButton.disabled = true; doNotButton.disabled = true;
title.innerText = "Authenticating..."; title.innerText = "Authenticating...";
fetch(window.location.href.replace("127.0.0.1", "localhost").includes("//localhost:") ? "http://localhost:39194/api/login" : "https://multiprobe.eusv.net/api/login", { fetch(window.location.href.replace("127.0.0.1", "localhost").includes("//localhost:") ? "http://localhost:38194/api/login" : "https://multiprobe.eusv.net/api/login", {
method: "POST", method: "POST",
body: `username=${encodeURIComponent(username.value)}&password=${encodeURIComponent(password.value)}`, body: `username=${encodeURIComponent(username.value)}&password=${encodeURIComponent(password.value)}`,
headers: { headers: {