Merge pull request #904 from embark-framework/bug_fix/ipfs-own-cors

add CORS URL for local ipfs' own server
This commit is contained in:
Iuri Matias 2018-09-26 08:58:07 -04:00 committed by GitHub
commit b4dc48dc32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -28,7 +28,7 @@ class StorageProcessesLauncher {
}); });
} }
buildCors(storageName) buildCors()
{ {
let corsParts = []; let corsParts = [];
// add our webserver CORS // add our webserver CORS
@ -39,12 +39,11 @@ class StorageProcessesLauncher {
else corsParts.push('http://localhost:8000'); else corsParts.push('http://localhost:8000');
} }
// add all dapp connection storage // add all dapp connection storage
if(this.storageConfig.enabled) { if(this.storageConfig.enabled) {
this.storageConfig.dappConnection.forEach(dappConn => { this.storageConfig.dappConnection.forEach(dappConn => {
if(dappConn.provider === storageName) return; // do not add CORS URL for ourselves
if(dappConn.getUrl || dappConn.host){ if(dappConn.getUrl || dappConn.host){
// if getUrl is specified in the config, that needs to be included in cors // if getUrl is specified in the config, that needs to be included in cors
// instead of the concatenated protocol://host:port // instead of the concatenated protocol://host:port
if(dappConn.getUrl) { if(dappConn.getUrl) {
@ -114,7 +113,7 @@ class StorageProcessesLauncher {
action: constants.blockchain.init, options: { action: constants.blockchain.init, options: {
storageConfig: self.storageConfig, storageConfig: self.storageConfig,
blockchainConfig: self.blockchainConfig, blockchainConfig: self.blockchainConfig,
cors: self.buildCors(storageName) cors: self.buildCors()
} }
}); });