I start my local node using the following command:
geth --datadir "D:\EthereumLocalNode" --networkid 1114 console 2>> "D:\EthereumLocalNode\myLog.log" --rpc --rpccorsdomain "*" --nodiscover --nodekey boot.key
and until 2 weeks ago, I could successfully connect and query my blockchain in chrome browser using :
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
abi = JSON.parse('.....myContract abi here.....');
myContract = web3.eth.contract(abi);
contractInstance = myContract.at('...My Contract address in bc...');
Now I'm getting the following error in developer tool of chrome :
Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'null' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access.
However I can still connect to this node and send transactions using remix, or with a js script that I run with nodejs that can make transactions to exactly same node still using web3 , which in the first line starts with:
Web3 = require('web3');
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
and this works fine.
So I'm guessing something has changed with the way Chrome works since the last one or two updates.
There are people complaining about Chrome's latest updates about something has changed with CORS. Anyways, I dont know what to do with CORS or how to change its settings.
Do I need to:
- change the way I start my node?
- change something in Chrome settings?
- or add some lines to my javascript code I use in my html.
Would be glad if someone helped me here.