0

**Hi, I am doing a sample project on Ethereum where 2 fields ( Emp name, Emp Id) will be taken from the UI and set those values using a smart contract and show the values back to UI. Getting below 2 errors.Please help me out to solve this.

  1. Failed to load http://localhost:8545/: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'null' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute. t.send @ web3.min.js:1

  2. Uncaught Error: CONNECTION ERROR: Couldn't connect to node http://localhost:8545. at Object.InvalidConnection (web3.min.js:1) at t.send (web3.min.js:1) at n.send (web3.min.js:1) at l.accounts (web3.min.js:1) at index.html:41 InvalidConnection @ web3.min.js:1 t.send @ web3.min.js:1 n.send @ web3.min.js:1 (anonymous) @ web3.min.js:1 (anonymous) @ index.html:41

0

You need to allow remote connections to ethereum node. I am assuming you are trying to connect to remote ethereum node. To allow ethereum node a connection requests from other devices on which geth is not running you'll need to use --rpcaddr and --rpccorsdomain flags to allow external RPC connections.

Use the following command for initiating geth

geth --datadir "path to data directory" --networkid 9876 --rpcport "8545" --rpcaddr "0.0.0.0" --rpccorsdomain "*"
  • path to data directory means? – Subhra Sankha Bose Sep 24 '18 at 3:23
  • --datadir to specify the directory for private ethereum blockchain. This is good practice when you are interacting with different chains. – Soham Lawar Sep 24 '18 at 4:54

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.