diff --git a/static/js/app.js b/static/js/app.js index c2c014f..00956b1 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -1,3 +1,11 @@ +function websocketPrefix() { + if (window.location.protocol == "https:") { + return "wss" + } else { + return "ws" + } +} + /* ansi_up.js * author : Dru Nelson * license : MIT diff --git a/templates/index.html b/templates/index.html index e2dd163..4dc00d7 100644 --- a/templates/index.html +++ b/templates/index.html @@ -45,7 +45,7 @@ } }) - ws = new WebSocket('ws://' + document.domain + ':' + location.port + '/index-ws'); + ws = new WebSocket(websocketPrefix() + '://' + document.domain + ':' + location.port + '/index-ws'); ws.onmessage = function (event) { var message = JSON.parse(event.data); diff --git a/templates/job.html b/templates/job.html index 3d8be0b..419eaa8 100644 --- a/templates/job.html +++ b/templates/job.html @@ -50,7 +50,7 @@ } }) - ws = new WebSocket('ws://' + document.domain + ':' + location.port + '/job-<{ job.id }>-ws'); + ws = new WebSocket(websocketPrefix() + '://' + document.domain + ':' + location.port + '/job-<{ job.id }>-ws'); ws.onmessage = function (event) { var message = JSON.parse(event.data);