fix(control): followers update live, phones use the page address, master is visible (1.77.2)
This commit is contained in:
1 parent
0589fe5f65
commit
a4e734dd74
13 files changed
+119
-22
No files matched your search
@@ -0,0 +1,14 @@
|
||||
// The saved backend URL is shared by every browser. "localhost" saved on the race laptop
|
||||
// means the laptop itself, so a phone or another computer (page opened on the laptop's IP)
|
||||
// uses the address it opened the page on instead.
|
||||
const LOOPBACK_HOST = /^(localhost|127\.\d+\.\d+\.\d+|\[::1\]|::1)$/i;
|
||||
|
||||
export function resolveBackendUrl(saved, { protocol = "", hostname = "", origin = "" } = {}) {
|
||||
const pageUrl = protocol.startsWith("http") && hostname ? origin : "http://127.0.0.1:8081";
|
||||
const value = String(saved || "").trim().replace(/\/+$/, "");
|
||||
if (!value) return pageUrl;
|
||||
let savedHost = "";
|
||||
try { savedHost = new URL(value).hostname; } catch { return pageUrl; }
|
||||
if (LOOPBACK_HOST.test(savedHost) && !LOOPBACK_HOST.test(hostname) && protocol.startsWith("http")) return pageUrl;
|
||||
return value;
|
||||
}
|
||||
Reference in new issue
Block a user