From 53269a805b521b3bdc64ec034a4c93a93426db7d Mon Sep 17 00:00:00 2001 From: Simon Lindh Date: Thu, 29 Aug 2019 01:05:46 +0200 Subject: [PATCH] Proxy websocket when running local environment. --- backend/src/index.ts | 4 ++-- frontend/proxy.conf.json | 5 +++++ frontend/src/app/services/api.service.ts | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index c0a327230..ef6475169 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -50,8 +50,8 @@ class MempoolSpace { statistics.startStatistics(); fiatConversion.startService(); - let opts = { - host: "127.0.0.1", + const opts = { + host: '127.0.0.1', port: 8999 }; this.server.listen(opts, () => { diff --git a/frontend/proxy.conf.json b/frontend/proxy.conf.json index 8a5402c52..bd32da01d 100644 --- a/frontend/proxy.conf.json +++ b/frontend/proxy.conf.json @@ -2,5 +2,10 @@ "/api": { "target": "http://localhost:8999/", "secure": false + }, + "/ws": { + "target": "http://localhost:8999/", + "secure": false, + "ws": true } } \ No newline at end of file diff --git a/frontend/src/app/services/api.service.ts b/frontend/src/app/services/api.service.ts index e0bf4b052..3b3f20185 100644 --- a/frontend/src/app/services/api.service.ts +++ b/frontend/src/app/services/api.service.ts @@ -6,8 +6,8 @@ import { Observable } from 'rxjs'; import { MemPoolService } from './mem-pool.service'; import { tap, retryWhen, delay } from 'rxjs/operators'; -const WEB_SOCKET_PROTOCOL = (document.location.protocol == 'https:') ? 'wss:' : '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 + ':' + document.location.port + '/ws'; const API_BASE_URL = '/api/v1'; @Injectable({