fix(overlay): overlay windows read from the server that served them, no 'Server disconnected' over OBS on localhost (1.89.24)
This commit is contained in:
1 parent
d74d8cf38f
commit
259945799d
6 files changed
+26
-5
No files matched your search
@@ -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
|
||||
|
||||
Generated
+2
-2
@@ -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",
|
||||
|
||||
+1
-1
@@ -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": {
|
||||
|
||||
+4
-1
@@ -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 } = {}) {
|
||||
|
||||
+6
-1
@@ -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 = "";
|
||||
|
||||
@@ -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");
|
||||
});
|
||||
Reference in new issue
Block a user