From 264290f2fe614ae980bb03215caf0cb54e5db804 Mon Sep 17 00:00:00 2001 From: Antoine Motet Date: Mon, 13 Nov 2017 18:06:07 +0100 Subject: [PATCH] Handle WebSockets over HTTPS --- client/src/ws.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/ws.js b/client/src/ws.js index ab46ffe..3358acc 100644 --- a/client/src/ws.js +++ b/client/src/ws.js @@ -13,7 +13,8 @@ const connect = () => { throw new Error('WebSocket not closed') } - ws = new WebSocket('ws://' + location.host + '/ws') + const protocol = window.location.protocol == 'https:' ? 'wss:' : 'ws:' + ws = new WebSocket(protocol + '//' + window.location.host + '/ws') ws.onopen = event => { ws.onmessage = event => {