Skip to content

Commit d1b2b53

Browse files
committed
Support ws with HTTPS
1 parent 5066217 commit d1b2b53

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

API/Backend/Config/routes/configs.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -668,18 +668,24 @@ function openWebSocket(body, response, info, forceClientUpdate) {
668668
}
669669

670670
const port = parseInt(process.env.PORT || "8888", 10);
671-
const path = `ws://localhost:${port}${
671+
const path = `${
672+
process.env.HTTPS == "true" ? "wss" : "ws"
673+
}://localhost:${port}${
672674
process.env.WEBSOCKET_ROOT_PATH || process.env.ROOT_PATH || ""
673675
}/`;
674-
const ws = new WebSocket(path);
675-
ws.onopen = function () {
676-
const data = {
677-
info,
678-
body,
679-
forceClientUpdate,
676+
try {
677+
const ws = new WebSocket(path);
678+
ws.onopen = function () {
679+
const data = {
680+
info,
681+
body,
682+
forceClientUpdate,
683+
};
684+
ws.send(JSON.stringify(data));
680685
};
681-
ws.send(JSON.stringify(data));
682-
};
686+
} catch (err) {
687+
console.log(err);
688+
}
683689
}
684690

685691
// === Quick API Functions ===

0 commit comments

Comments
 (0)