storage procs launcher -- canonicalHost

This commit is contained in:
Michael Bradley, Jr 2018-07-15 15:35:01 -05:00
parent eb62dab1eb
commit 6ebd0dd0a5
1 changed files with 6 additions and 2 deletions

View File

@ -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;