[SOLVED] XMLHttpRequest failed

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?

1 Like

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).

1 Like

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
Moralis2

This could help too, I stuck

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.

1 Like

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>
1 Like

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

don’t now how to reach this tab

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).

1 Like

sorry still get the error…
just saw that theres something wrong with my app state

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.

1 Like

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.