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({
|
const storageProcessesLauncher = new StorageProcessesLauncher({
|
||||||
logger: engine.logger,
|
logger: engine.logger,
|
||||||
events: engine.events,
|
events: engine.events,
|
||||||
storageConfig: engine.config.storageConfig
|
storageConfig: engine.config.storageConfig,
|
||||||
|
webServerConfig: engine.config.webServerConfig
|
||||||
});
|
});
|
||||||
return storageProcessesLauncher.launchProcess(platform.toLowerCase(), (err) => {
|
return storageProcessesLauncher.launchProcess(platform.toLowerCase(), (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ class StorageProcessesLauncher {
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
this.storageConfig = options.storageConfig;
|
this.storageConfig = options.storageConfig;
|
||||||
|
this.webServerConfig = options.webServerConfig;
|
||||||
this.processes = {};
|
this.processes = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +34,12 @@ class StorageProcessesLauncher {
|
||||||
silent: true,
|
silent: true,
|
||||||
exitCallback: self.processExited.bind(this, storageName)
|
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) => {
|
self.processes[storageName].on('result', constants.storage.initiated, (msg) => {
|
||||||
if (msg.error) {
|
if (msg.error) {
|
||||||
|
|
|
@ -8,6 +8,7 @@ class SwarmProcess extends ProcessWrapper {
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
super();
|
super();
|
||||||
this.storageConfig = options.storageConfig;
|
this.storageConfig = options.storageConfig;
|
||||||
|
this.webServerConfig = options.webServerConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
startSwarmDaemon() {
|
startSwarmDaemon() {
|
||||||
|
@ -15,8 +16,12 @@ class SwarmProcess extends ProcessWrapper {
|
||||||
if (!this.storageConfig.account || !this.storageConfig.account.address || !this.storageConfig.account.password) {
|
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';
|
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(
|
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) =>
|
{silent: true}, (err, _stdout, _stderr) =>
|
||||||
{
|
{
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
Loading…
Reference in New Issue