-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Web3@1.0.0-beta.50 (Webkit, Gecko) CORS Error #2559
Comments
Just as a note, I believe this isn't specific to beta 50 or the latest Firefox release, and that this has been an issue since much earlier. |
You're right I believe the issue is with the underlying browser engines. From what I can see all browsers mobile or desktop using Webkit or Gecko have this issue. The only browser engine I know that doesn't have this issue it Blink the Chrome desktop engine, and that's why I get these issues in iOS because chrome mobile uses Webkit. Edit: Brave Desktop works just fine too :) |
You have to configure the Access-Control-Allow-Origin header. Example: new Web3(
new Web3.providers.HttpProvider(
'https://rinkeby.infura.io/v3/key',
{
headers: [{
name: 'Access-Control-Allow-Origin',
value: 'https://rinkeby.infura.io/v3/key'
}]
}
)
); |
When setting the header like recommended above I get a preflight error
My understanding was that Infura should be setting those headers in the response. Also reading the web3 docs to see how I missed those options for provider and I see this: "Object - HttpProvider: The HTTP provider is deprecated, as it won’t work for subscriptions." |
possibly related #1802 |
Thanks for the test. I'll test and fix it today. |
Description
Calling method on web3.eth.Contract web3js in Firefox, Safari, and iOS browsers throws a CORS error, same method call will succeed in Chrome desktop only.
Expected behavior
Actual behavior
Steps to reproduce the behavior
Error Logs
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://rinkeby.infura.io/v3/key. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).[Learn More]
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://rinkeby.infura.io/v3/key. (Reason: CORS request did not succeed).
Gists
Versions
The text was updated successfully, but these errors were encountered: