Use WebsocketProvider as HttpProvider is deprecated
Issue
An attempt to use web3.js with an EVM node fails with the following error:
Access to XMLHttpRequest at 'https://nd-123-456-789.p2pify.com/3c6e0b8a9c15224a8228b9a98ca1531'
from origin 'http://12.345.67.890' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Cause
You are attempting to use a deprecated HttpProvider.
There is no CORS policy for WebSocket.
Solution
Use WebsocketProvider, which is the standard for web3.js.
If you have any questions, feel free to contact Chainstack support by emailing support@chainstack.com or by submitting this form.
Comments
0 comments
Article is closed for comments.