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
+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 = "";
|
||||
|
||||
Reference in new issue
Block a user