CORS errors when using BSC Archive Node as HttpProvider

When using the BSC Archive node as HttpProvider, I’m instantly greeted with the following CORS error:

Access to XMLHttpRequest at 'https://speedy-nodes-nyc.moralis.io/{redacted}/bsc/mainnet/archive' from origin 'http://localhost:3000' 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.

Obviously this is coming from localhost, but we’re having the same issues in production.

You can reconstruct this problem with the following code:

const web3 = new Web3(
    new Web3.providers.HttpProvider(
      'https://speedy-nodes-nyc.moralis.io/{redacted}/bsc/mainnet/archive',
      { timeout: 10000 }
    )
)

web3.eth.getBlockNumber().then(console.log).catch(console.error)

The reason I think this might be a technical problem is that we’ve been reporting error events from Moralis using Sentry. As you can see, since this morning there is a major peak.

I’m not sure if I can share my Node ID here safely, that’s why it’s redacted. Any help would be appreciated.

1 Like

It looks like I also get that error, we are going to investigate, thanks for reporting

1 Like

Thanks man! Let me know if you have any news :).

It should be fixed now

I am running into a similar issue with the Ropsten node it does not pass the Access-Control-Allow-Origin header I know this is not a problem on my side because if I switch to my own alchemy node it works fine.

Hey @maxall41

Does it stop work after a delay or doesn’t work at all?

Please send me your speedy-node URL to the DM

it does not work at all

I can’t seem to be able to send any private messages but here is the URL:
https://speedy-nodes-nyc.moralis.io/{redacted}/eth/ropsten

this works for me with ropsten speedy node

you need to replace {redacted} with what you have in https://admin.moralis.io/speedyNodes
in case that you used {redacted} there

Yeah, I didn’t actually put {redacted} there I think it may have something to do with web3-react and the NetworkConnector connector. Because the sample code you provided works for me with my URL. Does anybody know why this might be happening?

If the code from @cryptokid works for you so what code didn’t work?

It actually seems like it has changed from a CORS error to a 415 error Failed to load resource: the server responded with a status of 415 () when trying to activate the network connector like this:
web3React.activate(network) oddly enough the sample code still works. So I’m pretty sure it’s a web3-react issue. This is how I am initializing the connector:

import {NetworkConnector} from '@web3-react/network-connector';

export const network = new NetworkConnector({
  urls: {
    3: 'https://speedy-nodes-nyc.moralis.io/{redacted}/eth/ropsten',
    1: 'https://speedy-nodes-nyc.moralis.io/{redacted}/eth/mainnet',
    43113:
      'https://speedy-nodes-nyc.moralis.io/{redacted}/avalanche/testnet',
    43114:
      'https://speedy-nodes-nyc.moralis.io/{redacted}/avalanche/mainnet',
  },
  defaultChainId: 3,
});

I can’t seem to be able to find anyone else who is running into this issue one thing to note about my web3-react config is that I did not install the full package just the core package and the connectors I needed might that be causing the issue?

Here is an image of my network view: