@@ -4,6 +4,7 @@ const utils = require('../../utils/utils');
44const ProcessLauncher = require ( '../../process/processLauncher' ) ;
55const constants = require ( '../../constants' ) ;
66const StorageUtils = require ( './storageUtils' ) ;
7+ const { canonicalHost} = require ( '../../utils/host' ) ;
78
89class StorageProcessesLauncher {
910 constructor ( options ) {
@@ -46,6 +47,9 @@ class StorageProcessesLauncher {
4647 // remove /ipfs or /bzz: from getUrl if it's there
4748 let getUrlParts = dappConn . getUrl . split ( '/' ) ;
4849 getUrlParts = getUrlParts . slice ( 0 , 3 ) ;
50+ let host = canonicalHost ( getUrlParts [ 2 ] . split ( ':' ) [ 0 ] ) ;
51+ let port = getUrlParts [ 2 ] . split ( ':' ) [ 1 ] ;
52+ getUrlParts [ 2 ] = port ? [ host , port ] . join ( ':' ) : host ;
4953 corsParts . push ( getUrlParts . join ( '/' ) ) ;
5054 }
5155 // in case getUrl wasn't specified, use a built url
@@ -59,12 +63,12 @@ class StorageProcessesLauncher {
5963 if ( this . blockchainConfig . enabled ) {
6064 // add our rpc endpoints to CORS
6165 if ( this . blockchainConfig . rpcHost && this . blockchainConfig . rpcPort ) {
62- corsParts . push ( `http://${ this . blockchainConfig . rpcHost } :${ this . blockchainConfig . rpcPort } ` ) ;
66+ corsParts . push ( `http://${ canonicalHost ( this . blockchainConfig . rpcHost ) } :${ this . blockchainConfig . rpcPort } ` ) ;
6367 }
6468
6569 // add our ws endpoints to CORS
6670 if ( this . blockchainConfig . wsRPC && this . blockchainConfig . wsHost && this . blockchainConfig . wsPort ) {
67- corsParts . push ( `ws://${ this . blockchainConfig . wsHost } :${ this . blockchainConfig . wsPort } ` ) ;
71+ corsParts . push ( `ws://${ canonicalHost ( this . blockchainConfig . wsHost ) } :${ this . blockchainConfig . wsPort } ` ) ;
6872 }
6973 }
7074 return corsParts ;
0 commit comments