I am working on an Next.js dapp, where I am using ConnectKit and Wagmi to connect to the MetaMask wallet. The problem I am facing is that whenever I try to programmatically switch a network I get the following error in MetaMask:
MetaMask encountered an error. Try again by closing and reopening the popup, or contact support here. Error details. Message: Invalid or no prefix found for localhost:3000
In wagmi config I have mainnet and goerli defined as chains. If I am already connected in the browser to my MetaMask wallet to either mainnet or goerli, then when I click on the Connect Wallet button (the button is the official component from ConnectKit) I can connect without any issues. However in case that I was first connected to some other chain that is not defined in the wagmi config, then I will get this error. So lets say I was connected with MetaMask in my browser to Polygon chain and then I try to click on the Connect wallet button, I will not be able to connect and will get the above mentioned error. This same error happens, if I try to programmatically switch network by using wagmi in my app. Generally speaking it seems that as soon as I try to switch networks programmatically I get this error and I can’t seem to fix it. If I try to switch networks manually in MetaMask, I don’t have any issues.
I am not sure if this is a Wagmi or MetaMask issue, I am hoping that someone might be able to look at the MetaMask error and maybe based on that error spot, what could be the issue. I had this same issue last week, back then I was using Rainbowkit and thought that might be causing the issues, so I switched to Web3Modal and that seemed to fix the issue. But today the error returned (while using Web3Modal library), so I tried switching to ConnectKit, but error persists. If anyone has any ideas what might be causing this issues, I would appreciate any advice.
I’m facing the same error and I don’t use libs to switch networks, just calling ethereum.request directly. There is a strange fact that in testing version of our application it works fine but in production or localhost it doesn’t. The problem appeared in the latest version of MetaMask because my co-worker who is still on the previous version had no problems
I had this error with two applications, but in one of them network switching works ok now, but in another it still doesn’t work. It such an odd issue, because in both of this apps I am using the same libraries to connect to the wallet, both are Next.js apps, but in one of them everything works ok (for now) and in the other any sort of network switching results in the mentioned MetaMask error.
I’m having the same problem in my application as well, the staging environment works fine, production environment breaks when we try to switch networks.
The problem first started appearing after MetaMask’s release v11.0.0
This is the error message I get on the MetaMask Extension:
Message: Invalid or no prefix found for "https://luxy.io"
Code: Error
Stack: Error: Invalid or no prefix found for "https://luxy.io"
at n.getSnapPrefix (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-1.js:1:75297)
at F (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-7.js:10:158232)
at t.getSnapName (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-7.js:10:158399)
at x (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-9.js:1:50677)
at va (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:60111)
at Mu (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:105038)
at As (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:90901)
at Rs (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:90826)
at xs (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:88166)
at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:46516
at n.unstable_runWithPriority (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:514297)
at Xo (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:46225)
at ti (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:46461)
at ei (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:46396)
at Es (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:88543)
at dl (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:113783)
at render (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:115706)
at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-8.js:1:199025
The only fix that I could find for this error, was downgrading my MetaMask back to version 10.35.1. I tried various things to fix it, but this seems to be only solution for now, that works for me. As soon as I downgraded the MetaMask version, my app started working OK again and I could switch networks without any issues.
Again, for whatever reason this error initially affected two dapps that I was working on, both used the same libraries to connect to the wallet, but on one of them this error resolved on its own, without any changes added by me. The other dapp only started working after I downgraded my MetaMask wallet to the previous version. So I still don’t know why this error happens, but downgrading MetaMask seems to fix it.
I created a new issue, it doesn’t let me post a link to it, since I am a new user in this community. The issue has the ID value of #21040, with the title of Invalid or no prefix found error on network switch.
I created an issue regarding this bug on MetaMask GitHub issues page. I used your website as an example in the steps to reproduce the bug, since my websites aren’t deployed yet.
Just to let you know, if you haven’t noticed it yet, one way that I found to fix this error, is to downgrade MetaMask to the previous version. I tried to connect to your app through MetaMask wallet on my Firefox browser, which was downgraded to the previous version and network switching works as it should there. But if I try to do the same thing on my Chrome browser, where I have the latest version of MetaMask, the issue persists.
I’m facing the same issue locally as well as production . Message: Invalid or no prefix found for “”
Code: Error
Stack:
Error: Invalid or no prefix found for “”
at n.getSnapPrefix (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-1.js:1:75297)
at F (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-7.js:10:158232)
at t.getSnapName (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/common-7.js:10:158399)
at x (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-9.js:1:50677)
at va (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:60111)
at Mu (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:105038)
at As (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:90901)
at Rs (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:90826)
at xs (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:88166)
at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:46516
at n.unstable_runWithPriority (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:514297)
at Xo (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:46225)
at ti (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:46461)
at ei (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:46396)
at Es (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:88543)
at dl (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:113783)
at render (chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-3.js:1:115706)
at chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn/ui-8.js:1:199025