Hello, I am getting this error when I try to initialize Moralis from my Next.js application.
I need help to fix this, tried a lot.
Hello if youâre using moralis-v1, what is your Moralis serverUrl (dapp URL)? Which version of moralis (and react-moralis if youâre using that) are you using?
The Server is awake, and these are my depencies:
âmoralisâ: â^2.4.0â,
"moralis-v1": "^1.11.0",
"next": "12.3.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-moralis": "^1.4.2"
Thanks for your help
And these one, I forgot it âmoralisâ: â^2.4.0â,
How have you connected to your Moralis server e.g. with Moralis.start
or using MoralisProvider
? Also react-moralis
can be used only with moralis-v1
, not with [email protected]
(or 2.0).
Nothing changed when I remove [email protected] but nice to know
I use:
const { Moralis } = useMoralis();
Moralis.start({serverUrl: ââŚâ, appId: ââŚâ})
After removing I still get this error, maybe fixing this will be the solution
What is your Moralis serverUrl / dapp URL?
Have you wrapped your Component (_app.js) with <MoralisProvider>
as in these instructions? You donât need to use Moralis.start. But check your serverUrl
and appId
in Moralis.start.
Are you using that CDN link (unpkg.com) anywhere in your code? That is for vanilla JS usage and you shouldnât be using that version (Moralis 2.0) anyway.
This could help too, I stuck
You can ignore those warnings (web3auth, magic-sdk, etc.) for now.
I wrapped it inside the _document.js file like this
< body>
< Main />
<React.StrictMode>
< NextScript />
</React.StrictMode>
< /body>
Hope itâs the right syntax in this case, because the _app.js file looks like this
function MyApp({ Component, pageProps }) {
return <Component {âŚpageProps} />
}
I use no cdn, that the cdn I used before doesnât work anymore was one reason to change the framework to next.js
Ahh wait I see the provider is missing, i try now
In order to use hooks like useMoralis
, you need to use MoralisProvider
. You can do:
<MoralisProvider serverUrl="" appId="">
<Component {...pageProps} />
</MoralisProvider>
Alright, thank you a lot that worked very well. The XMLHttpRequest Error is gone!
I am just new to both, nextjs and moralis.
Maybe you can give me some reference for installing the 1inch plugin too?
I tried the docs but the pages from are screenshots are not shown and I am confused
Plugins like 1inch have been deprecated/discontinued so theyâre no longer available unfortunately. You can use 1inch API directly - this is what the plugins were doing (wrapper around the API).
Nice thank you! Thats another reason why my former app doesnât worked anymore
What is your serverUrl / dapp URL? The server may need to be restarted.
Thats another reason why my former app doesnât worked anymore
If the plugins were installed previously, they should still work, but you canât install them anymore on new servers.
Unfortunately I deletet the application with the installed plugin a few hours ago. I thought maybe creating a new one is the solution to fix the bugs.
But anyway, its interesting to implement the wrapper by myself, I will try this.
my Dapp Url is: https://f2jmarfgdjdn.usemoralis.com:2053/server
By the way are you working for moralis or are you a user too?
I have to quit now, not much hours till work for me.
I will answer tomorrow.