Skip to content

Commit 3885128

Browse files
config -- canonicalHost, defaultHost
1 parent 6d482cf commit 3885128

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/core/config.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const utils = require('../utils/utils.js');
55
const path = require('path');
66
const deepEqual = require('deep-equal');
77
const constants = require('../constants');
8+
const {canonicalHost, defaultHost} = require('../utils/host');
89

910
var Config = function(options) {
1011
const self = this;
@@ -106,6 +107,9 @@ Config.prototype._updateBlockchainCors = function(){
106107
// remove /ipfs or /bzz: from getUrl if it's there
107108
let getUrlParts = storageConfig.upload.getUrl.split('/');
108109
getUrlParts = getUrlParts.slice(0, 3);
110+
let host = canonicalHost(getUrlParts[2].split(':')[0]);
111+
let port = getUrlParts[2].split(':')[1];
112+
getUrlParts[2] = port ? [host, port].join(':') : host;
109113
corsParts.push(getUrlParts.join('/'));
110114
}
111115
// use our modified getUrl or in case it wasn't specified, use a built url
@@ -246,7 +250,7 @@ Config.prototype.loadStorageConfigFile = function() {
246250
"upload": {
247251
"provider": "ipfs",
248252
"protocol": "http",
249-
"host": "localhost",
253+
"host" : defaultHost,
250254
"port": 5001,
251255
"getUrl": "http://localhost:8080/ipfs/"
252256
},
@@ -281,7 +285,9 @@ Config.prototype.loadCommunicationConfigFile = function() {
281285
"provider": "whisper",
282286
"available_providers": ["whisper"],
283287
"connection": {
284-
"host": "localhost", "port": 8546, "type": "ws"
288+
"host": defaultHost,
289+
"port": 8546,
290+
"type": "ws"
285291
}
286292
}
287293
};
@@ -293,7 +299,9 @@ Config.prototype.loadCommunicationConfigFile = function() {
293299

294300
Config.prototype.loadWebServerConfigFile = function() {
295301
var configObject = {
296-
"enabled": true, "host": "localhost", "port": 8000
302+
"enabled": true,
303+
"host": defaultHost,
304+
"port": 8000
297305
};
298306

299307
let configFilePath = this._getFileOrOject(this.configDir, 'webserver', 'webserver');

0 commit comments

Comments
 (0)