From 1d190c3a649c242be69720f90131bd18cba8649e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20K=C3=B6llmann?= Date: Wed, 30 Oct 2019 14:13:21 +0100 Subject: [PATCH] Make client websocket aware of the used protocol (http/https -> ws/wss) --- src/client/networking.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/networking.js b/src/client/networking.js index e7ad3d6..e6ff9bc 100644 --- a/src/client/networking.js +++ b/src/client/networking.js @@ -6,7 +6,8 @@ import { processGameUpdate } from './state'; const Constants = require('../shared/constants'); -const socket = io(`ws://${window.location.host}`, { reconnection: false }); +const socketProtocol = (window.location.protocol === 'https') ? 'wss' : 'ws'; +const socket = io(`${socketProtocol}://${window.location.host}`, { reconnection: false }); const connectedPromise = new Promise(resolve => { socket.on('connect', () => { console.log('Connected to server!');