瀏覽代碼

fixing ws / wss problem

Nicolas Winkler 4 年之前
父節點
當前提交
e04764eb0b
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      static/comm.js

+ 4 - 1
static/comm.js

@@ -120,7 +120,10 @@ $(function() {
         if (connection != null) {
             disconnect();
         }
-        var uri = 'ws://' + window.location.host + '/ws/';
+
+        var prot = document.location.protocol == 'https:' ? 'wss://' : 'ws://';
+
+        var uri = prot + window.location.host + '/ws/';
         connection = new WebSocket(uri);
 
         connection.onopen = function() {