From 0b65c79a8963046eaec78dc13158f4b5803ec9b6 Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Sat, 13 May 2017 02:14:20 +0200 Subject: [PATCH] Do not hardcode websocket host --- socialdragon/templates/index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/socialdragon/templates/index.html b/socialdragon/templates/index.html index ad8575d..0f39b87 100755 --- a/socialdragon/templates/index.html +++ b/socialdragon/templates/index.html @@ -95,7 +95,11 @@ var queue = []; var archive = []; -var exampleSocket = new WebSocket("ws://Marvins-MacBook-Pro.local:8000/ws"); +// Construct websocket url +var loc = window.location; +var ws_url = ((loc.protocol === "https:") ? "wss://" : "ws://") + loc.host + "/ws"; + +var exampleSocket = new WebSocket(ws_url); exampleSocket.onopen = function (event) { console.log("WS: Connection open"); };