3

I'm trying to connect to my local node using the --unsafe-rpc-external --unsafe-ws-external flags when running the node. I can connect to the node through a node.js script, but not from a browser because the connection keeps getting refused.

enter image description here

Am I missing something here?

3
  • Try adding --rpc-cors all. If you are running in --dev mode the default is to allow all origins.
    – Burak
    May 6, 2022 at 19:30
  • 2
    @Burak The -rpc-cors all worked, many thanks!
    – adrielvb
    May 6, 2022 at 21:22
  • 1
    @Burak - make it an answer for upvotes :)
    – Nuke
    May 9, 2022 at 15:44

1 Answer 1

2

Try adding --rpc-cors all. If you are running in --dev mode the default is to allow all origins.

If you view the node executable help (i.e. ./target/release/node-template --help) the output includes:

--rpc-cors <ORIGINS>
  Specify browser Origins allowed to access the HTTP & WS RPC servers.
            
  A comma-separated list of origins (protocol://domain or special `null` value). Value of
  `all` will disable origin validation. Default is to allow localhost and
  <https://polkadot.js.org> origins. When running in --dev mode the default 
  is to allow all origins.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.