Skip to content

Commit f07c022

Browse files
committed
fix: health endpoint check
1 parent f960376 commit f07c022

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

frontend/src/utils/sfu-client.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,20 @@ class SFUClient {
9595
this.sfuUrl = sfu_url;
9696
this.sfuPort = sfu_port;
9797

98-
// Test SFU server accessibility first
99-
const sfuEndpoint = `${sfu_url}:${sfu_port}`;
98+
let sfuEndpoint;
99+
try {
100+
const urlObj = new URL(sfu_url);
101+
const defaultPort = urlObj.protocol === "https:" ? "443" : "80";
102+
// If port is empty/null OR matches default for the scheme, omit.
103+
if (!sfu_port || String(sfu_port) === defaultPort) {
104+
sfuEndpoint = urlObj.origin;
105+
} else {
106+
sfuEndpoint = `${urlObj.protocol}//${urlObj.hostname}:${sfu_port}`;
107+
}
108+
} catch (e) {
109+
sfuEndpoint = sfu_port ? `${sfu_url}:${sfu_port}` : sfu_url;
110+
}
100111

101-
// Try to fetch the SFU health endpoint first
102112
try {
103113
const healthResponse = await fetch(`${sfuEndpoint}/health`);
104114
if (!healthResponse.ok) {

0 commit comments

Comments
 (0)