From 8910eba396cf3504beac9d31fd9feb697118a4e0 Mon Sep 17 00:00:00 2001 From: wiz Date: Fri, 23 Aug 2019 00:04:14 +0900 Subject: [PATCH] Fix websocket URL to work with both clearnet and onion --- frontend/src/app/services/api.service.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/services/api.service.ts b/frontend/src/app/services/api.service.ts index b577097c5..f54a746a6 100644 --- a/frontend/src/app/services/api.service.ts +++ b/frontend/src/app/services/api.service.ts @@ -6,7 +6,10 @@ import { Observable } from 'rxjs'; import { MemPoolService } from './mem-pool.service'; import { tap, retryWhen, delay } from 'rxjs/operators'; -const WEB_SOCKET_URL = 'ws://' + document.location.hostname + '/ws'; +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 API_BASE_URL = '/api/v1'; @Injectable({