From 7dc3d8d8718c15902d2def78296332d24e70b624 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sun, 17 Nov 2019 04:07:38 +0100 Subject: [PATCH] Detect protocol for websocket Signed-off-by: Michael Mayer --- frontend/src/common/websocket.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/common/websocket.js b/frontend/src/common/websocket.js index a51f7f8a7..37e387062 100644 --- a/frontend/src/common/websocket.js +++ b/frontend/src/common/websocket.js @@ -2,7 +2,9 @@ import Sockette from "sockette"; import Event from "pubsub-js"; const host = window.location.host; -const Socket = new Sockette("ws://" + host + "/api/v1/ws", { +const prot = ('https:' === document.location.protocol ? 'wss://' : 'ws://'); + +const Socket = new Sockette(prot + host + "/api/v1/ws", { timeout: 5e3, onopen: e => { console.log('Connected!', e);