mirror of
https://github.com/hay-kot/homebox.git
synced 2024-11-25 10:05:43 +00:00
fix https connection
This commit is contained in:
parent
9fa17bec90
commit
a3cce59a2a
1 changed files with 6 additions and 1 deletions
|
@ -13,7 +13,12 @@ let socket: WebSocket | null = null;
|
||||||
const listeners = new Map<ServerEvent, (() => void)[]>();
|
const listeners = new Map<ServerEvent, (() => void)[]>();
|
||||||
|
|
||||||
function connect(onmessage: (m: EventMessage) => 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 = () => {
|
ws.onopen = () => {
|
||||||
console.debug("connected to server");
|
console.debug("connected to server");
|
||||||
|
|
Loading…
Reference in a new issue