File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments