From daac439e9a538aafa1944e81c1eac5d58d9394ac Mon Sep 17 00:00:00 2001 From: wiz Date: Fri, 23 Aug 2019 00:12:35 +0900 Subject: [PATCH] Set websocket URL protocol based on document.location.protocol --- frontend/src/app/services/api.service.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/services/api.service.ts b/frontend/src/app/services/api.service.ts index f54a746a6..e0bf4b052 100644 --- a/frontend/src/app/services/api.service.ts +++ b/frontend/src/app/services/api.service.ts @@ -6,10 +6,8 @@ import { Observable } from 'rxjs'; import { MemPoolService } from './mem-pool.service'; import { tap, retryWhen, delay } from 'rxjs/operators'; -let WEB_SOCKET_PROTOCOL = 'wss://'; -if (document.location.hostname.indexOf('onion') != -1) - WEB_SOCKET_PROTOCOL = 'ws://' -const WEB_SOCKET_URL = WEB_SOCKET_PROTOCOL + document.location.hostname + '/ws'; +const WEB_SOCKET_PROTOCOL = (document.location.protocol == 'https:') ? 'wss:' : 'ws:'; +const WEB_SOCKET_URL = WEB_SOCKET_PROTOCOL + '//' + document.location.hostname + '/ws'; const API_BASE_URL = '/api/v1'; @Injectable({