Remove hardcoded websocket host
This commit is contained in:
@@ -37,7 +37,10 @@ export default class WebsocketService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createAndConnect() {
|
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);
|
url.searchParams.append('accessToken', this.accessToken);
|
||||||
|
|
||||||
console.debug('connecting to ', url.toString());
|
console.debug('connecting to ', url.toString());
|
||||||
@@ -84,8 +87,8 @@ export default class WebsocketService {
|
|||||||
if (this.handleMessage) {
|
if (this.handleMessage) {
|
||||||
this.handleMessage(socketEvent);
|
this.handleMessage(socketEvent);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (err) {
|
||||||
console.error(e, e.data);
|
console.error(err, err.data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user