diff --git a/CHANGELOG.md b/CHANGELOG.md index 464b516..b7b58d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ The application version is maintained in `package.json` and displayed in the adm No changes recorded yet. +## 1.89.24 - 2026-11-14 + +### Fixed + +- An overlay (OBS, TV, speaker ...) opened as `localhost` or `127.0.0.1` on the race computer, while the saved server address was its network IP, showed "Server disconnected" over the stream and no data. Overlay windows now always read from the server that served them. + ## 1.89.23 - 2026-11-14 ### Changed diff --git a/package-lock.json b/package-lock.json index 70e1e14..39545d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "rc-racecore", - "version": "1.89.23", + "version": "1.89.24", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "rc-racecore", - "version": "1.89.23", + "version": "1.89.24", "hasInstallScript": true, "dependencies": { "better-sqlite3": "^12.11.1", diff --git a/package.json b/package.json index a1ceb7a..d496d6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rc-racecore", - "version": "1.89.23", + "version": "1.89.24", "private": true, "description": "RC RaceCore live timing and race control with AMMC ingest and SQLite persistence", "engines": { diff --git a/src/app.js b/src/app.js index 90819c1..8a9e7b6 100644 --- a/src/app.js +++ b/src/app.js @@ -7260,7 +7260,10 @@ function getDefaultBackendUrl() { } function getBackendUrl() { - return resolveBackendUrl(state.settings.backendUrl, window.location); + // Overlay windows read from the server that served them (see resolveBackendUrl). + const params = new URLSearchParams(window.location.search); + const overlayPage = /^\/public-overlay(\/|$)/i.test(window.location.pathname) || (params.get("view") === "overlay" && params.has("overlayMode")); + return resolveBackendUrl(state.settings.backendUrl, window.location, { sameOrigin: overlayPage }); } async function refreshServerBackups({ render = true } = {}) { diff --git a/src/backend_url.js b/src/backend_url.js index 8e9d21f..ce01770 100644 --- a/src/backend_url.js +++ b/src/backend_url.js @@ -3,8 +3,13 @@ // 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 = "" } = {}) { +// An overlay window (OBS, TV, speaker ...) is always served by the RaceCore server it reads, so it +// uses the page's own address: opened as localhost while the saved address is the laptop's LAN IP +// (OBS on the race computer), the saved one is another origin, the server refuses it and the +// overlay showed "Server disconnected" over the stream. +export function resolveBackendUrl(saved, { protocol = "", hostname = "", origin = "" } = {}, { sameOrigin = false } = {}) { const pageUrl = protocol.startsWith("http") && hostname ? origin : "http://127.0.0.1:8081"; + if (sameOrigin && protocol.startsWith("http") && hostname) return pageUrl; const value = String(saved || "").trim().replace(/\/+$/, ""); if (!value) return pageUrl; let savedHost = ""; diff --git a/tests/backend_url.test.js b/tests/backend_url.test.js index 80f3b1c..a0d32a4 100644 --- a/tests/backend_url.test.js +++ b/tests/backend_url.test.js @@ -13,3 +13,10 @@ test("a phone on the laptop's IP ignores the laptop's saved localhost address", assert.equal(resolveBackendUrl("", phone), "http://192.168.1.46:8081"); assert.equal(resolveBackendUrl("", { protocol: "file:" }), "http://127.0.0.1:8081"); }); + +test("an overlay window always reads from the server that served it", () => { + const obsOnLaptop = { protocol: "http:", hostname: "127.0.0.1", origin: "http://127.0.0.1:8081" }; + assert.equal(resolveBackendUrl("http://192.168.1.46:8081", obsOnLaptop, { sameOrigin: true }), "http://127.0.0.1:8081"); + assert.equal(resolveBackendUrl("http://192.168.1.46:8081", obsOnLaptop), "http://192.168.1.46:8081", "the admin page keeps the saved address"); + assert.equal(resolveBackendUrl("http://192.168.1.46:8081", { protocol: "file:" }, { sameOrigin: true }), "http://192.168.1.46:8081", "not served over http: saved address"); +});