diff --git a/frontend/src/Editor/Editor.jsx b/frontend/src/Editor/Editor.jsx index 867fcc632a..0474eaead7 100644 --- a/frontend/src/Editor/Editor.jsx +++ b/frontend/src/Editor/Editor.jsx @@ -107,9 +107,16 @@ class Editor extends React.Component { } } + getWebsocketUrl = () => { + const re = /https?:\/\//g; + if (re.test(config.apiUrl)) return config.apiUrl.replace(/(^\w+:|^)\/\//, '').replace('/api', ''); + + return window.location.host; + }; + initWebSocket = () => { // TODO: add retry policy - const socket = new WebSocket(`ws://${config.apiUrl.replace(/(^\w+:|^)\/\//, '').replace('/api', '')}`); + const socket = new WebSocket(`ws://${this.getWebsocketUrl()}`); // Connection opened socket.addEventListener('open', function (event) {