Ethereum POA Cannot Connect via Browser: The 'Access-Control-Allow-Origin' header has a value 'http://null'
Category: azure blockchain
samw2 on Tue, 14 Aug 2018 16:14:08
I have the Ethereum POA consortium deployed and running. Admin page is up and running as well, blocks are being created. I can connect and submit transactions via Remix just fine now.
However, when I tried to connect with web3 in the Browser, I get this error:
my JS code:
web3 = new Web3(new Web3.providers.HttpProvider("http://XXXXXXXXXXX.cloudapp.azure.com:8540"));
Sorry if it is a basic question, I'm quite new to this, so any suggestions would be great thanks!
Microsoft Azure Blockchain Team on Tue, 14 Aug 2018 19:23:51
We haven't seen this issue before and couldn't get repro locally.
Could you please try to put JS code into local file and run node instead?
samw2 on Wed, 15 Aug 2018 10:23:22
Ran from node and it works fine. This issue only seems to occur with the browser. Anything else I can try?
samw2 on Fri, 17 Aug 2018 13:14:20
I am still facing this problem, need help! I tore down and redeployed a new POA instance but the problem still persists (it connects fine via Remix and node via console), BUT not on the browser
web3.js:4340 Failed to load http://XXXXXX.azure.com:8540/: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'http://null' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access.
Microsoft Azure Blockchain Team on Sun, 19 Aug 2018 22:18:52
We recommend POA user to use node or Remix to access Ethereum RPC endpoint.
If you do need use browser, please try altering the security of your web browser to avoid CORS errors.
Dev team is looking into possible solutions from our end, will reply back in business hours.
Microsoft Azure Blockchain Team on Wed, 22 Aug 2018 18:07:07
Our endpoint config is using following setting: cors = ["all"].
We tried to repro but looks like connecting via browser works fine.
Could you please try this:
1 Install MetaTask
2 Open a http page, e.g. http://www.play-hookey.com/htmltest/
3 Open console and run following:
web3 = new Web3(new Web3.providers.HttpProvider("http://***.cloudapp.azure.com:8540"));
If you can get true return from isConnected(), connection is established successfully.
Let us know if you have further questions.