Web3.js: CORS issue with 1.2.0 on Firefox and Safari

Created on 29 Jul 2019  Â·  6Comments  Â·  Source: ChainSafe/web3.js

Steps to reproduce:

  • Import web3 1.2.0
  • var web3 = new Web3(new Web3.providers.HttpProvider('https://rinkeby.infura.io/'));
  • web3.eth.getTransaction('0xd540f813d46953f5bf7c0b3797572ff6b73eee0eeadfac071baee0da9a7a9b5a').then(console.log);

You will get the following error messages:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://rinkeby.infura.io/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://rinkeby.infura.io/. (Reason: CORS request did not succeed).
Error: Invalid JSON RPC response: ""

Doesn't happen on Brave or Chrome or the new Edge, but happens on Firefox, Safari and Safari Mobile.

1.x bug

Most helpful comment

@cgewecke I will back port this fix this week to include it in the next release.

@felixwatts The next version will be published after devcon when I‘m back home.

All 6 comments

Is there a fix in sight, this isn't the first time this issue has come up. It was in earlier versions as well. Is anyway we can get a client test in place to send a test call to infura from webkit before a release? You could use something like phantomJS or another headless webkit testing framework.

this is pretty serious guys

@felixwatts Just leaving a note - it looks like this is fixed on the 2.0 branch with #2564.

Will prioritize back-porting that to 1.x but it could still be a bit before it makes it to a published patch.

@cgewecke I will back port this fix this week to include it in the next release.

@felixwatts The next version will be published after devcon when I‘m back home.

I can't install 1.2.2 version. I tried with node versions: 10.16.3, 12.10.0, 12.13.0, 13.1.0

Can you post the errors you are getting @davidtacer? Or better yet, open another issue with them? Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dhl picture dhl  Â·  3Comments

FradSer picture FradSer  Â·  3Comments

zamoore picture zamoore  Â·  3Comments

xpepermint picture xpepermint  Â·  3Comments

sundbry picture sundbry  Â·  3Comments