From 0b176e701390fd04d0fe53b57f2eba146e0d33be Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 10 Nov 2016 20:45:03 +0100 Subject: [PATCH] Cater for home.parity hostname in dappsUrl (#3341) * Cater for home.parity hostname * Cater for 0.0.0.0 & default dappsInterface * Extra check --- js/src/secureApi.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/js/src/secureApi.js b/js/src/secureApi.js index 6bb9d38ea..ed665a5e6 100644 --- a/js/src/secureApi.js +++ b/js/src/secureApi.js @@ -26,6 +26,7 @@ export default class SecureApi extends Api { this._connectState = sysuiToken === 'initial' ? 1 : 0; this._needsToken = false; this._dappsPort = 8080; + this._dappsInterface = null; this._signerPort = 8180; console.log('SecureApi:constructor', sysuiToken); @@ -100,10 +101,12 @@ export default class SecureApi extends Api { Promise .all([ this.parity.dappsPort(), + this.parity.dappsInterface(), this.parity.signerPort() ]) - .then(([dappsPort, signerPort]) => { + .then(([dappsPort, dappsInterface, signerPort]) => { this._dappsPort = dappsPort.toNumber(); + this._dappsInterface = dappsInterface; this._signerPort = signerPort.toNumber(); }); @@ -122,7 +125,17 @@ export default class SecureApi extends Api { } get dappsUrl () { - return `http://${window.location.hostname}:${this._dappsPort}`; + let hostname; + + if (window.location.hostname === 'home.parity') { + hostname = 'dapps.parity'; + } else if (!this._dappsInterface || this._dappsInterface === '0.0.0.0') { + hostname = window.location.hostname; + } else { + hostname = this._dappsInterface; + } + + return `http://${hostname}:${this._dappsPort}`; } get signerPort () {