mirror of https://github.com/embarklabs/embark.git
set cors domain depending on the webserverConfig
This commit is contained in:
parent
460c2e98f1
commit
72115bb636
|
@ -91,7 +91,8 @@ class Embark {
|
|||
const storageProcessesLauncher = new StorageProcessesLauncher({
|
||||
logger: engine.logger,
|
||||
events: engine.events,
|
||||
storageConfig: engine.config.storageConfig
|
||||
storageConfig: engine.config.storageConfig,
|
||||
webServerConfig: engine.config.webServerConfig
|
||||
});
|
||||
return storageProcessesLauncher.launchProcess(platform.toLowerCase(), (err) => {
|
||||
if (err) {
|
||||
|
|
|
@ -8,6 +8,7 @@ class StorageProcessesLauncher {
|
|||
this.logger = options.logger;
|
||||
this.events = options.events;
|
||||
this.storageConfig = options.storageConfig;
|
||||
this.webServerConfig = options.webServerConfig;
|
||||
this.processes = {};
|
||||
}
|
||||
|
||||
|
@ -33,7 +34,12 @@ class StorageProcessesLauncher {
|
|||
silent: true,
|
||||
exitCallback: self.processExited.bind(this, storageName)
|
||||
});
|
||||
self.processes[storageName].send({action: constants.blockchain.init, options: {storageConfig: self.storageConfig}});
|
||||
self.processes[storageName].send({
|
||||
action: constants.blockchain.init, options: {
|
||||
storageConfig: self.storageConfig,
|
||||
webServerConfig: self.webServerConfig
|
||||
}
|
||||
});
|
||||
|
||||
self.processes[storageName].on('result', constants.storage.initiated, (msg) => {
|
||||
if (msg.error) {
|
||||
|
|
|
@ -8,6 +8,7 @@ class SwarmProcess extends ProcessWrapper {
|
|||
constructor(options) {
|
||||
super();
|
||||
this.storageConfig = options.storageConfig;
|
||||
this.webServerConfig = options.webServerConfig;
|
||||
}
|
||||
|
||||
startSwarmDaemon() {
|
||||
|
@ -15,8 +16,12 @@ class SwarmProcess extends ProcessWrapper {
|
|||
if (!this.storageConfig.account || !this.storageConfig.account.address || !this.storageConfig.account.password) {
|
||||
return 'Account address and password are needed in the storage config to start the Swarm process';
|
||||
}
|
||||
let corsDomain = 'http://localhost:8000';
|
||||
if (self.webServerConfig && self.webServerConfig && self.webServerConfig.host && self.webServerConfig.port) {
|
||||
corsDomain = `http://${self.webServerConfig.host}:${self.webServerConfig.port}`;
|
||||
}
|
||||
const child = shelljs.exec(
|
||||
`${this.storageConfig.swarmPath || 'swarm'} --bzzaccount ${this.storageConfig.account.address} --password ${this.storageConfig.account.password} --corsdomain http://localhost:8000 --ens-api ''`,
|
||||
`${this.storageConfig.swarmPath || 'swarm'} --bzzaccount ${this.storageConfig.account.address} --password ${this.storageConfig.account.password} --corsdomain ${corsDomain} --ens-api ''`,
|
||||
{silent: true}, (err, _stdout, _stderr) =>
|
||||
{
|
||||
if (err) {
|
||||
|
|
Loading…
Reference in New Issue