From 889dae9c7b536d75f66ebaf41a9d4e6b7279fea2 Mon Sep 17 00:00:00 2001 From: Dmitry Lyzo Date: Mon, 20 Sep 2021 00:22:56 +0300 Subject: [PATCH] Fix server candidates --- src/scripts/clientUtils.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/scripts/clientUtils.js b/src/scripts/clientUtils.js index b7e41a48dc..768fcf8ccc 100644 --- a/src/scripts/clientUtils.js +++ b/src/scripts/clientUtils.js @@ -27,19 +27,22 @@ export async function serverAddress() { const urls = await webSettings.getServers(); if (urls.length === 0) { - // Don't use app URL as server URL - if (window.NativeShell) { + // Otherwise use computed base URL + let url; + const index = window.location.href.toLowerCase().lastIndexOf('/web'); + if (index != -1) { + url = window.location.href.substring(0, index); + } else { + // fallback to location without path + url = window.location.origin; + } + + // Don't use bundled app URL (file:) as server URL + if (url.startsWith('file:')) { return Promise.resolve(); } - // Otherwise use computed base URL - const index = window.location.href.toLowerCase().lastIndexOf('/web'); - if (index != -1) { - urls.push(window.location.href.substring(0, index)); - } else { - // fallback to location without path - urls.push(window.location.origin); - } + urls.push(url); } console.debug('URL candidates:', urls);