Hello, I’m stuck on an error, trying to search on forum, documentation, I still didn’t find something useful to solve it.
I’m using a custom connector for wallet connect, taken from here:
this is my code where I’m using it
export const LoginComponent = ({ closeModal }) => {
const { authenticate, isAuthenticated } = useMoralis();
const [authError, setAuthError] = useState(null);
const [isAuthenticating, setIsAuthenticating] = useState(false);
async function walletConnectLogin() {
try {
setAuthError(null);
setIsAuthenticating(true);
await Moralis.enableWeb3({});
await Moralis.start({
apiKey: process.env.NEXT_PUBLIC_MORALIS_API_KEY,
serverUrl: process.env.NEXT_PUBLIC_MORALIS_SERVER_URL,
appId: process.env.NEXT_PUBLIC_MORALIS_APP_ID
});
const { account, chainId } = Moralis;
if (!account) {
throw new Error(
"Connecting to chain failed, as no connected account was found"
);
}
if (!chainId) {
throw new Error(
"Connecting to chain failed, as no connected chain was found"
);
}
const { message } = await Moralis.Cloud.run("requestMessage", {
address: account,
chain: parseInt(chainId, 16),
network: "evm",
});
await authenticate({ signingMessage: message, connector: WalletConnectWeb3Connector });
} catch (error) {
setAuthError(error);
} finally {
setIsAuthenticating(false);
}
}
useEffect(() => {
if (isAuthenticated) {
closeModal()
}
}, [closeModal, isAuthenticated])
return (
<div className='w-full text-center py-12 grid px-8'>
<button onClick={() => walletConnectLogin()}>
Walletconnect</button>
<div className='pt-6 text-center text-xs animate-pulse font-bold'>{isAuthenticating ? "Authenticating..." : ""}</div>
</div>
)
}
I’m using as RPCs in the specific file the following:
137: `https://matic.getblock.io/<API ID>/mainnet/`,
80001: `https://matic.getblock.io/<API ID>/testnet/`,
with my api ID
Now the behavior is the following:
this is working perfectly on a browser (e.g. Chrome) where I have the MetaMask extension enabled. Is considering the right RPCs, when I use wallet connect a popup on my MetaMask app on the phone ask me to sign, if I sign from the popup, I’m correctly logged in from my desktop Chrome browser.
As soon as I use it on mobile, or on a browser where I don’t have MetaMask, e.g. Safari, immediately I receive these three errors in loop:
[Error] XMLHttpRequest cannot load https://speedy-nodes-nyc.moralis.io/WalletConnect/polygon/mumbai due to access control checks.
Failed to load resource: Preflight response is not successful. Status code: 429
index.js:51
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
undefined
My question is, why in the first case is going on the right RPCs, and in the second case is trying to reach https://speedy-nodes-nyc.moralis.io/WalletConnect/polygon/mumbai ?
Any suggestion?
Thanks