mirror of https://github.com/embarklabs/embark.git
Merge pull request #381 from embark-framework/features/cors-auto
Add 'auto' setting for geth CORS and websockets origin
This commit is contained in:
commit
9e91915bce
|
@ -103,14 +103,14 @@ class GethCommands {
|
|||
if (config.wsOrigins) {
|
||||
if (config.wsOrigins === '*') {
|
||||
console.log('==================================');
|
||||
console.log('rpcCorsDomain set to *');
|
||||
console.log('wsOrigins set to *');
|
||||
console.log('make sure you know what you are doing');
|
||||
console.log('==================================');
|
||||
}
|
||||
cmd += "--wsorigins \"" + config.wsOrigins + "\" ";
|
||||
} else {
|
||||
console.log('==================================');
|
||||
console.log('warning: cors is not set');
|
||||
console.log('warning: wsOrigins is not set');
|
||||
console.log('==================================');
|
||||
}
|
||||
}
|
||||
|
|
14
lib/index.js
14
lib/index.js
|
@ -39,7 +39,19 @@ class Embark {
|
|||
|
||||
blockchain(env, client) {
|
||||
this.context = [constants.contexts.blockchain];
|
||||
return require('./cmds/blockchain/blockchain.js')(this.config.blockchainConfig, client, env).run();
|
||||
let blockchainConfig = this.config.blockchainConfig;
|
||||
let storageConfig = this.config.storageConfig;
|
||||
let webServerConfig = this.config.webServerConfig;
|
||||
|
||||
if(blockchainConfig.rpcCorsDomain === 'auto') {
|
||||
if(webServerConfig) blockchainConfig.rpcCorsDomain = `http://${webServerConfig.host}:${webServerConfig.port}`;
|
||||
if(storageConfig) blockchainConfig.rpcCorsDomain += `${blockchainConfig.rpcCorsDomain.length ? ',' : ''}http://${storageConfig.host}:${storageConfig.port}`;
|
||||
}
|
||||
if(blockchainConfig.wsOrigins === 'auto') {
|
||||
if(webServerConfig) blockchainConfig.wsOrigins = `http://${webServerConfig.host}:${webServerConfig.port}`;
|
||||
if(storageConfig) blockchainConfig.wsOrigins += `${blockchainConfig.wsOrigins.length ? ',' : ''}http://${storageConfig.host}:${storageConfig.port}`;
|
||||
}
|
||||
return require('./cmds/blockchain/blockchain.js')(blockchainConfig, client, env).run();
|
||||
}
|
||||
|
||||
simulator(options) {
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
"maxpeers": 0,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"rpcCorsDomain": "auto",
|
||||
"account": {
|
||||
"password": "config/development/password"
|
||||
},
|
||||
"targetGasLimit": 8000000,
|
||||
"wsOrigins": "http://localhost:8000",
|
||||
"wsOrigins": "auto",
|
||||
"wsRPC": true,
|
||||
"wsHost": "localhost",
|
||||
"wsPort": 8546,
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
"maxpeers": 0,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"rpcCorsDomain": "auto",
|
||||
"account": {
|
||||
"password": "config/development/password"
|
||||
},
|
||||
"targetGasLimit": 8000000,
|
||||
"wsOrigins": "http://localhost:8000",
|
||||
"wsOrigins": "auto",
|
||||
"wsRPC": true,
|
||||
"wsHost": "localhost",
|
||||
"wsPort": 8546,
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
"maxpeers": 0,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"rpcCorsDomain": "auto",
|
||||
"account": {
|
||||
"password": "development/password"
|
||||
},
|
||||
"targetGasLimit": 8000000,
|
||||
"wsOrigins": "http://localhost:8000",
|
||||
"wsOrigins": "auto",
|
||||
"wsRPC": true,
|
||||
"wsHost": "localhost",
|
||||
"wsPort": 8546
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
"maxpeers": 0,
|
||||
"rpcHost": "localhost",
|
||||
"rpcPort": 8545,
|
||||
"rpcCorsDomain": "http://localhost:8000",
|
||||
"rpcCorsDomain": "auto",
|
||||
"account": {
|
||||
"password": "config/development/password"
|
||||
},
|
||||
"targetGasLimit": 8000000,
|
||||
"wsOrigins": "http://localhost:8000",
|
||||
"wsOrigins": "auto",
|
||||
"wsRPC": true,
|
||||
"wsHost": "localhost",
|
||||
"wsPort": 8546
|
||||
|
|
Loading…
Reference in New Issue