0

Remove hardcoded websocket host

This commit is contained in:
Gabe Kangas 2022-10-09 21:16:46 -07:00
parent de87b78768
commit 8f0541a0f1
No known key found for this signature in database
GPG Key ID: 9A56337728BC81EA

View File

@ -37,7 +37,10 @@ export default class WebsocketService {
}
createAndConnect() {
const url = new URL('ws://localhost:8080/ws');
const url = new URL(window.location.toString());
url.protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
url.pathname = '/ws';
url.port = window.location.port === '3000' ? '8080' : window.location.port;
url.searchParams.append('accessToken', this.accessToken);
console.debug('connecting to ', url.toString());
@ -84,8 +87,8 @@ export default class WebsocketService {
if (this.handleMessage) {
this.handleMessage(socketEvent);
}
} catch (e) {
console.error(e, e.data);
} catch (err) {
console.error(err, err.data);
return;
}