From 3885128e180b935aa9ed27b68d5d37790dbe5366 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Sun, 15 Jul 2018 15:33:48 -0500 Subject: [PATCH] config -- canonicalHost, defaultHost --- lib/core/config.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/core/config.js b/lib/core/config.js index 608d1f58..785c75b2 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -5,6 +5,7 @@ const utils = require('../utils/utils.js'); const path = require('path'); const deepEqual = require('deep-equal'); const constants = require('../constants'); +const {canonicalHost, defaultHost} = require('../utils/host'); var Config = function(options) { const self = this; @@ -106,6 +107,9 @@ Config.prototype._updateBlockchainCors = function(){ // remove /ipfs or /bzz: from getUrl if it's there let getUrlParts = storageConfig.upload.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('/')); } // use our modified getUrl or in case it wasn't specified, use a built url @@ -246,7 +250,7 @@ Config.prototype.loadStorageConfigFile = function() { "upload": { "provider": "ipfs", "protocol": "http", - "host": "localhost", + "host" : defaultHost, "port": 5001, "getUrl": "http://localhost:8080/ipfs/" }, @@ -281,7 +285,9 @@ Config.prototype.loadCommunicationConfigFile = function() { "provider": "whisper", "available_providers": ["whisper"], "connection": { - "host": "localhost", "port": 8546, "type": "ws" + "host": defaultHost, + "port": 8546, + "type": "ws" } } }; @@ -293,7 +299,9 @@ Config.prototype.loadCommunicationConfigFile = function() { Config.prototype.loadWebServerConfigFile = function() { var configObject = { - "enabled": true, "host": "localhost", "port": 8000 + "enabled": true, + "host": defaultHost, + "port": 8000 }; let configFilePath = this._getFileOrOject(this.configDir, 'webserver', 'webserver');