3

In the spirit of decentralization, I would like my decentralized application, a JavaScript application running in a user's browser, to be allowed to communicate with the Tezos node of their choice.

Because of CORS rules, JavaScript can only fetch data from the server that served it, or that server can act as proxy to communicate with other Tezos nodes, or a server with a CORS policy that allows it. According to this question, the browser JavaScript could also communicate with a tezos node that is run with those flags, but this would limit the app to communicating with Tezos nodes that have that setting.

Is there any other strategy to make a JavaScript program in the browser communicate directly with a Tezos node without going though the backend that served it?

0

The tezos-node RPC respects the CORS rules like any other HTTP server. If you want the JavaScript application to communicate directly to the node, you just need to make sure you are using a node that supports CORS. If the node does not, you can ask the manager to update the node's config.json file to include the following keys and values:

    "cors-origin": ["*"],
    "cors-headers": ["GET","POST"],

This should allow any JavaScript front end to communicate to the node, unless the browser enforces more restrictions.

There is one JavaScript libraries I know of for interacting directly with a node: taquito.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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