mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-06 06:48:21 +00:00
add websocket url fallback as window.location.host (#1374)
This commit is contained in:
parent
5055aed8e6
commit
6f1e3c19db
1 changed files with 8 additions and 1 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue