Kusama-提供的主机头未列入白名单

时间:2019-09-02 08:49:53

标签: substrate

通过以下方式开始将草s节点作为一项服务

polkadot --port 30333 --rpc-external --rpc-port 9933  --ws-external --ws-port 9944

现在,我正在尝试通过对http://IP:9933和此JSON有效负载的POST请求来调用该节点:

{"id":1, "jsonrpc":"2.0", "method": "state_getMetadata"}

我被禁止访问是403:

  

提供的主机标头未列入白名单。

任何想法设置中缺少什么?

1 个答案:

答案 0 :(得分:2)

您将需要配置CORS标头。您可以添加--rpc-cors=all以禁用来源验证,也可以传递允许的来源,例如--rpc-cors=https://your.website.url

https://github.com/paritytech/substrate/blob/fc3adc87dc806237eb7371c1d21055eea1702be0/core/cli/src/params.rs#L346

/// Specify browser Origins allowed to access the HTTP & WS RPC servers.
/// It's a comma-separated list of origins (protocol://domain or special `null` value).
/// Value of `all` will disable origin validation.
/// Default is to allow localhost, https://polkadot.js.org and https://substrate-ui.parity.io origins.
/// When running in --dev mode the default is to allow all origins.
#[structopt(long = "rpc-cors", value_name = "ORIGINS", parse(try_from_str = "parse_cors"))]
pub rpc_cors: Option<Cors>,