From ca7a46224d7c88bb0c9376452b7733e5e6bb4122 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Sun, 15 Jul 2018 15:35:01 -0500 Subject: [PATCH] storage procs launcher -- canonicalHost --- .../storageProcesses/storageProcessesLauncher.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/processes/storageProcesses/storageProcessesLauncher.js b/lib/processes/storageProcesses/storageProcessesLauncher.js index 2ac624a0..6501638a 100644 --- a/lib/processes/storageProcesses/storageProcessesLauncher.js +++ b/lib/processes/storageProcesses/storageProcessesLauncher.js @@ -4,6 +4,7 @@ const utils = require('../../utils/utils'); const ProcessLauncher = require('../../process/processLauncher'); const constants = require('../../constants'); const StorageUtils = require('./storageUtils'); +const {canonicalHost} = require('../../utils/host'); class StorageProcessesLauncher { constructor(options) { @@ -46,6 +47,9 @@ class StorageProcessesLauncher { // remove /ipfs or /bzz: from getUrl if it's there let getUrlParts = dappConn.getUrl.split('/'); getUrlParts = getUrlParts.slice(0, 3); + let host = canonicalHost(getUrlParts[2].split(':')[0]); + let port = getUrlParts[2].split(':')[1]; + getUrlParts[2] = port ? [host, port].join(':') : host; corsParts.push(getUrlParts.join('/')); } // in case getUrl wasn't specified, use a built url @@ -59,12 +63,12 @@ class StorageProcessesLauncher { if(this.blockchainConfig.enabled) { // add our rpc endpoints to CORS if(this.blockchainConfig.rpcHost && this.blockchainConfig.rpcPort){ - corsParts.push(`http://${this.blockchainConfig.rpcHost}:${this.blockchainConfig.rpcPort}`); + corsParts.push(`http://${canonicalHost(this.blockchainConfig.rpcHost)}:${this.blockchainConfig.rpcPort}`); } // add our ws endpoints to CORS if(this.blockchainConfig.wsRPC && this.blockchainConfig.wsHost && this.blockchainConfig.wsPort){ - corsParts.push(`ws://${this.blockchainConfig.wsHost}:${this.blockchainConfig.wsPort}`); + corsParts.push(`ws://${canonicalHost(this.blockchainConfig.wsHost)}:${this.blockchainConfig.wsPort}`); } } return corsParts;