Fix default CORS. (#7388)
This commit is contained in:
parent
c74c8c1ac1
commit
42dd3addea
@ -764,7 +764,8 @@ impl Configuration {
|
||||
}
|
||||
|
||||
fn cors(cors: Option<&String>) -> Option<Vec<String>> {
|
||||
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<Vec<String>> {
|
||||
@ -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()]));
|
||||
}
|
||||
|
@ -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![]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<UiConfiguration> 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,
|
||||
|
Loading…
Reference in New Issue
Block a user