make socket url dynamic

This commit is contained in:
ntr
2019-09-03 10:57:57 +10:00
parent 2728be796e
commit fbb7e58f3c
2 changed files with 7 additions and 9 deletions
+3 -6
View File
@@ -1,11 +1,8 @@
const toast = require('izitoast');
const cbor = require('borc');
const socketUrl = () => {
if (process.env.NODE_ENV === 'production') return 'wss://mnml.gg/api/ws';
if (process.env.NODE_ENV === 'staging') return 'wss://sixtysix.pro/api/ws';
return 'ws://localhost/api/ws';
};
const SOCKET_URL =
`${window.location.protocol === 'https:' ? 'wss://' : 'ws://'}${window.location.host}/api/ws`;
function errorToast(err) {
console.error(err);
@@ -299,7 +296,7 @@ function createSocket(events) {
ws = null;
}
ws = new WebSocket(socketUrl());
ws = new WebSocket(SOCKET_URL);
ws.binaryType = 'arraybuffer';
// Listen for messages