diff --git a/README.md b/README.md index d308c36f7..61e65fb3b 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,7 @@ If you have any problems installing OpenWebRX, you should check out the server_hostname correctly, because it is left as \"localhost\". Now guessing hostname from page URL.",1); - ws_url="ws://"+(window.location.origin.split("://")[1])+"/ws/"; //guess automatically -> now default behaviour - //} + // Determine the home URL based on the current location + ws_url = "ws://" + window.location.host + window.location.pathname + "ws/"; + // We would like something like the following, but the URL() constructor doesn't + // do any useful URL normalisation. + //ws_url = new URL("ws/", "ws://" + window.location.host + window.location.pathname); + if (!("WebSocket" in window)) divlog("Your browser does not support WebSocket, which is required for WebRX to run. Please upgrade to a HTML5 compatible browser."); ws = new WebSocket(ws_url+client_id); diff --git a/openwebrx.py b/openwebrx.py index 07c91e1de..91acd70e2 100755 --- a/openwebrx.py +++ b/openwebrx.py @@ -407,7 +407,7 @@ def proc_read_thread(): def send_302(self,what): self.send_response(302) self.send_header('Content-type','text/html') - self.send_header("Location", "http://{0}:{1}/{2}".format(cfg.server_hostname,cfg.web_port,what)) + self.send_header("Location", "http://{0}/{1}".format(cfg.server_url,what)) self.end_headers() self.wfile.write("

Object moved

Please
click here to continue.".format(what)) @@ -670,7 +670,7 @@ def do_GET(self): replace_dictionary=( ("%[RX_PHOTO_DESC]",cfg.photo_desc), ("%[CLIENT_ID]", generate_client_id(self.client_address[0])) if "%[CLIENT_ID]" in data else "", - ("%[WS_URL]","ws://"+cfg.server_hostname+":"+str(cfg.web_port)+"/ws/"), + ("%[WS_URL]","ws://"+cfg.server_url+"/ws/"), ("%[RX_TITLE]",cfg.receiver_name), ("%[RX_LOC]",cfg.receiver_location), ("%[RX_QRA]",cfg.receiver_qra), diff --git a/sdrhu.py b/sdrhu.py index d06ae058e..58498748d 100755 --- a/sdrhu.py +++ b/sdrhu.py @@ -26,7 +26,7 @@ def run(continuously=True): if not cfg.sdrhu_key: return firsttime="(Your receiver is soon getting listed on sdr.hu!)" while True: - cmd = "wget --timeout=15 -4qO- https://sdr.hu/update --post-data \"url=http://"+cfg.server_hostname+":"+str(cfg.web_port)+"&apikey="+cfg.sdrhu_key+"\" 2>&1" + cmd = "wget --timeout=15 -4qO- https://sdr.hu/update --post-data \"url=http://"+cfg.server_url+"&apikey="+cfg.sdrhu_key+"\" 2>&1" print "[openwebrx-sdrhu]", cmd returned=subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).communicate() returned=returned[0]