Detect protocol for websocket

Signed-off-by: Michael Mayer <michael@liquidbytes.net>
This commit is contained in:
Michael Mayer 2019-11-17 04:07:38 +01:00
parent 824fb9d063
commit 7dc3d8d871

View file

@ -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);