make socket url dynamic
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user