Kusama - 提供的主机 header 未列入白名单
Kusama - Provided Host header is not whitelisted
已将 kusama 节点作为服务启动
polkadot --port 30333 --rpc-external --rpc-port 9933 --ws-external --ws-port 9944
现在我正在尝试使用 POST 请求 http://IP:9933 和此 JSON 有效载荷来调用节点:
{"id":1, "jsonrpc":"2.0", "method": "state_getMetadata"}
我收到 403 禁止响应:
Provided Host header is not whitelisted.
设置中缺少什么想法?
您将需要配置 CORS header。您可以添加 --rpc-cors=all
以禁用来源验证或传递允许的来源,例如 --rpc-cors=https://your.website.url
/// 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>,
已将 kusama 节点作为服务启动
polkadot --port 30333 --rpc-external --rpc-port 9933 --ws-external --ws-port 9944
现在我正在尝试使用 POST 请求 http://IP:9933 和此 JSON 有效载荷来调用节点:
{"id":1, "jsonrpc":"2.0", "method": "state_getMetadata"}
我收到 403 禁止响应:
Provided Host header is not whitelisted.
设置中缺少什么想法?
您将需要配置 CORS header。您可以添加 --rpc-cors=all
以禁用来源验证或传递允许的来源,例如 --rpc-cors=https://your.website.url
/// 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>,