mirror of
https://github.com/hay-kot/homebox.git
synced 2025-07-01 08:08:36 +00:00
fix websocket over secure connection (#542)
* fix https connection * explicity dependency
This commit is contained in:
parent
5438898b49
commit
0876deb1e9
3 changed files with 10 additions and 1 deletions
|
@ -13,7 +13,12 @@ let socket: WebSocket | null = null;
|
|||
const listeners = new Map<ServerEvent, (() => void)[]>();
|
||||
|
||||
function connect(onmessage: (m: EventMessage) => void) {
|
||||
const ws = new WebSocket(`ws://${window.location.host}/api/v1/ws/events`);
|
||||
let protocol = "ws";
|
||||
if (window.location.protocol === "https:") {
|
||||
protocol = "wss";
|
||||
}
|
||||
|
||||
const ws = new WebSocket(`${protocol}://${window.location.host}/api/v1/ws/events`);
|
||||
|
||||
ws.onopen = () => {
|
||||
console.debug("connected to server");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue