Web3auth (mumbai chain) blocked by CORS

it looks like https://rpc-mumbai.maticvigil.com/ doesn’t work for me either when I try to use it as a RPC url

mmhh so any ideas how I can get web3auth to work then w/ mumbai?

Try using another RPC from this page on the testnet tab.

That makes sense to me however Moralis doesn’t expose the parameter to point to a different RPC in the Moralis.authenticate() function. https://rpc-mumbai.maticvigil.com/ seems to be set by default if you choose the Mumbai chain.

it looks like something that web3auth provider can change

they could make an update for that

Any updates? Mine just stopped working for seemingly the same reasons…

Access to fetch at ‘https://rpc-mumbai.maticvigil.com/’ from origin ‘’ 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. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

The problem is related to that RPC url that stopped working. We are looking to see if we can find a solution.

Thanks. I talked to tech support on web3auth side and they said the same thing. This was suggested. https://docs.web3auth.io/api-reference/web/plugnplay#example

The issue doesnt seem to be resolved. Is there any other way we are able to test moralis web3auth on mumbai chain?

A temporarily solution for your local development is to change node_modules\moralis\lib\browser\Web3Connector\Web3AuthConnector.js so it uses another RPC:

// Build config
ethChainConfig = {
  chainNamespace: 'eip155',
  chainId: (0, _verifyChainId.default)(chainId)
}; // Build Web3Auth

to:

if (chainId === '0x13881') {
  ethChainConfig = {
    chainNamespace: 'eip155',
    chainId: (0, _verifyChainId.default)(chainId),
    rpcTarget: 'https://rpc-mumbai.matic.today'
  }; // Build Web3Auth

} else {
  ethChainConfig = {
    chainNamespace: 'eip155',
    chainId: (0, _verifyChainId.default)(chainId),
  }; // Build Web3Auth
}
1 Like

Thanks for your help.
But I am not sure why it is still going ‘https://rpc-mumbai.maticvigil.com/’ instead of the stated rpcTarget.
It does not seem to enter the if statement.

you changed that code directly in node modules in node_modules\moralis\lib\browser\Web3Connector\Web3AuthConnector.js ?

Make sure you restart your app server. Also that change will only work on the browser side of things.

Yes, i changed code directly in web3AuthConnector.js and restarted the app server.
Is there a way to console log so i am able to see the rpcTarget result?

Can you post what you’ve done in Web3AuthConnector.js as well as your Moralis authenticate code - the RPC change is still working from my end.

If you want to log it, add console.log("Current RPC", ethChainConfig.rpcTarget).

Although unfortunately it seems the same issue is happening occasionally with this different RPC as of today (but it doesn’t happen on each app load).

There is likely something wrong on Web3Auth’s side.

Below is what i done in Web3AuthConnector.js.
Interestingly, the console log is not found as well.

Below is my code for Moralis authentication.

Odd, can you doublecheck you are working with the same connector file at the path mentioned above moralis\lib\browser\Web3Connector. What does your package.json look like? Maybe there’s something else involved.

case 7:

  if (chainId === '0x13881') {
    ethChainConfig = {
      chainNamespace: 'eip155',
      chainId: (0, _verifyChainId.default)(chainId),
      rpcTarget: 'https://rpc-mumbai.matic.today'
    }; // Build Web3Auth

  } else {
    ethChainConfig = {
      chainNamespace: 'eip155',
      chainId: (0, _verifyChainId.default)(chainId),
    }; // Build Web3Auth
  }

  console.log("Current RPC", ethChainConfig.rpcTarget)

Any idea what is _N_E and where does it resides?
I verified I made the code change in Web3AuthConnector.js based on the directory you mentioned but it does not seems to be reflected.
The file I am editing is not correct?
I reinstalled the app server and copied only the pages and components over and I am still getting the same error.

I see node_modules folder there too, below that _N_E folder

what kind of project do you run: vanilla js, react, something else?

I got it to work.
It is because of the cache in the browser.
I am using Next.js.
I am not sure whether it is nature of Next.js or Web3Auth, there are openlogin data cache in the browser.
Once I cleared them, it is working.
Thank you!

2 Likes