diff --git a/parity/configuration.rs b/parity/configuration.rs index dc390d5e7..4f3e6dcba 100644 --- a/parity/configuration.rs +++ b/parity/configuration.rs @@ -764,7 +764,8 @@ impl Configuration { } fn cors(cors: Option<&String>) -> Option> { - cors.map(|ref c| c.split(',').map(Into::into).collect()) + // Never return `None` here (enables CORS for all hosts). + Some(cors.map(|ref c| c.split(',').map(Into::into).collect()).unwrap_or_default()) } fn rpc_cors(&self) -> Option> { @@ -1510,7 +1511,7 @@ mod tests { let conf2 = parse(&["parity", "--ipfs-api-cors", "http://parity.io,http://something.io"]); // then - assert_eq!(conf0.ipfs_cors(), None); + assert_eq!(conf0.ipfs_cors(), Some(vec![])); assert_eq!(conf1.ipfs_cors(), Some(vec!["*".into()])); assert_eq!(conf2.ipfs_cors(), Some(vec!["http://parity.io".into(),"http://something.io".into()])); } diff --git a/parity/ipfs.rs b/parity/ipfs.rs index 45c3f7062..ac9a4662b 100644 --- a/parity/ipfs.rs +++ b/parity/ipfs.rs @@ -34,8 +34,8 @@ impl Default for Configuration { enabled: false, port: 5001, interface: "127.0.0.1".into(), - cors: None, - hosts: Some(Vec::new()), + cors: Some(vec![]), + hosts: Some(vec![]), } } } diff --git a/parity/rpc.rs b/parity/rpc.rs index 18550c14c..da8986851 100644 --- a/parity/rpc.rs +++ b/parity/rpc.rs @@ -59,8 +59,8 @@ impl Default for HttpConfiguration { interface: "127.0.0.1".into(), port: 8545, apis: ApiSet::UnsafeContext, - cors: None, - hosts: Some(Vec::new()), + cors: Some(vec![]), + hosts: Some(vec![]), server_threads: 1, processing_threads: 0, } @@ -98,7 +98,7 @@ impl From for HttpConfiguration { interface: conf.interface, port: conf.port, apis: rpc_apis::ApiSet::UnsafeContext, - cors: None, + cors: Some(vec![]), hosts: conf.hosts, server_threads: 1, processing_threads: 0,