Merge pull request #1247 from ethcore/rpc-cors-fix

Fixing CORS settings for special values: * & null.
This commit is contained in:
Arkadiy Paronyan
2016-06-10 14:09:10 +02:00
committed by GitHub
2 changed files with 6 additions and 2 deletions

View File

@@ -75,7 +75,11 @@ impl RpcServer {
/// Start http server asynchronously and returns result with `Server` handle on success or an error.
pub fn start_http(&self, addr: &SocketAddr, cors_domains: Vec<String>) -> Result<Server, RpcServerError> {
let cors_domains = cors_domains.into_iter()
.map(jsonrpc_http_server::AccessControlAllowOrigin::Value)
.map(|v| match v.as_str() {
"*" => jsonrpc_http_server::AccessControlAllowOrigin::Any,
"null" => jsonrpc_http_server::AccessControlAllowOrigin::Null,
v => jsonrpc_http_server::AccessControlAllowOrigin::Value(v.into()),
})
.collect();
Server::start(addr, self.handler.clone(), cors_domains)
}