From c2e92111c114ee1462d23e894dcb2c4bd3ca984d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Struijk=20Holmen?= Date: Sun, 22 Nov 2020 04:07:29 +0100 Subject: [PATCH 1/2] restore base-url compatible approach --- src/scripts/clientUtils.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/scripts/clientUtils.js b/src/scripts/clientUtils.js index 84e029f827..9b1f8adcba 100644 --- a/src/scripts/clientUtils.js +++ b/src/scripts/clientUtils.js @@ -28,22 +28,19 @@ export async function serverAddress() { // TODO this makes things faster but it also blocks the wizard in some scenarios // if (current) return Promise.resolve(current); - const urls = []; - if (window.location.href.indexOf('/web/') !== -1) { - const split = window.location.href.split('/web/'); + // Use servers specified in config.json + const urls = await webSettings.getServers(); - for (let i = split.length - 1; i > 0; i--) { - urls.push(split.slice(0, i).join('/web/')); + // Otherwise, use computed base-url + if (urls.length == 0) { + const index = window.location.href.toLowerCase().lastIndexOf('/web'); + if (index != -1) { + urls.push(window.location.href.substring(0, index)); + } else { + // fall back to location without path + urls.push(window.location.origin); } } - urls.push(window.location.origin); - urls.push(`https://${window.location.hostname}:8920`); - - if (window.location.protocol === 'http') { - urls.push(`http://${window.location.hostname}:8096`); - } - - urls.push(...await webSettings.getServers()); console.debug('URL candidates:', urls); From ae4e1814c17a199005d2bfb7a2a5882d4f29a0ff Mon Sep 17 00:00:00 2001 From: hawken <1411903+hawken93@users.noreply.github.com> Date: Thu, 26 Nov 2020 16:46:55 +0100 Subject: [PATCH 2/2] grammar Co-authored-by: dkanada --- src/scripts/clientUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripts/clientUtils.js b/src/scripts/clientUtils.js index 9b1f8adcba..291202b2e0 100644 --- a/src/scripts/clientUtils.js +++ b/src/scripts/clientUtils.js @@ -31,13 +31,13 @@ export async function serverAddress() { // Use servers specified in config.json const urls = await webSettings.getServers(); - // Otherwise, use computed base-url + // Otherwise use computed base URL if (urls.length == 0) { const index = window.location.href.toLowerCase().lastIndexOf('/web'); if (index != -1) { urls.push(window.location.href.substring(0, index)); } else { - // fall back to location without path + // fallback to location without path urls.push(window.location.origin); } }