diff --git a/src/app/openlp-websocket.ts b/src/app/openlp-websocket.ts index fe83343..ae8f483 100644 --- a/src/app/openlp-websocket.ts +++ b/src/app/openlp-websocket.ts @@ -7,7 +7,8 @@ export function createWebSocket( endpoint = '' ): Observable { return new Observable((observer) => { - const ws = new WebSocket(`ws://${host}:${wsPort}/${endpoint}`); + const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; + const ws = new WebSocket(`${protocol}//${host}:${wsPort}/${endpoint}`); ws.onmessage = (e) => { const reader = new FileReader(); reader.onload = () => { diff --git a/src/app/openlp.service.ts b/src/app/openlp.service.ts index 81a069a..424d0e6 100644 --- a/src/app/openlp.service.ts +++ b/src/app/openlp.service.ts @@ -65,6 +65,7 @@ export class OpenLPService { private titleCasePipe: TitleCasePipe, private sentenceCasePipe: SentenceCasePipe, private translateService: TranslateService ) { + const protocol = window.location.protocol; const host = window.location.hostname; let port: string; if (environment.production) { @@ -73,7 +74,7 @@ export class OpenLPService { else { port = '4316'; } - this.apiURL = `http://${host}:${port}/api/v2`; + this.apiURL = `${protocol}//${host}:${port}/api/v2`; this.host = host; this.stateChanged$ = new EventEmitter(); this.webSocketStateChanged$ = new EventEmitter();