Hi Yomoo, thanks, but this is a different issue, like I said, Moralis works just fine in development mode, it doesnt when I do npm run build && npm run start
, in the thread that you provided, the person describes how to wrap the app in the MoralisProvider
which I have done, MoralisProvider
is the main wrapper around every single thing in my app, even my UserProvider
is within it, so its:
const App = ({ Component, pageProps }: AppProps) => {
return (
<MoralisProvider
appId='appid'
serverUrl=serverurl'
>
<UserProvider>
<ThemeProvider theme={theme}>
<Head>
<title>Trading Pal</title>
<meta
name='viewport'
content='width=device-width, initial-scale=1.0, user-scalable=no'
/>
</Head>
<GlobalStyles />
<Header />
<Component {...pageProps} />
<Footer />
</ThemeProvider>
</UserProvider>
</MoralisProvider>
);
};
And for the example that I started with that uses nothing additional:
import { MoralisProvider } from "react-moralis";
import "../styles/globals.css";
function MyApp({ Component, pageProps }) {
return (
<MoralisProvider
appId="appid"
serverUrl="serverurl"
>
<Component {...pageProps} />
</MoralisProvider>
);
}
export default MyApp;
As you can see its very barebones and it is reproducing the problem that I am having (coupled with the code from my first post)
The only different thing that I see in that persons post is that he is wrapping MoralisDappProvider
with MoralisProvider
but I cant find any such thing, either in the linked boilerplate code, or within Moralis itself, so it seem to me that this is some custom context that he did for himself and unless theres some magical code in there, I dont think that this is the problem.
Please let me reiterate this, because I think when people read the thread are missing it:
The app is working perfectly in dev mode the problem occurs only when the app is deployed, regardless of if its deployed locally (that meaning, running npm run build
and then npm run start
), or a hosting provider (that is irrelevant). As soon as I build and run it, it no longer sends requests to the Moralis server (getNativeBalance, getTokensBalance), they just do not get sent at all, confirmed by the Network tab, and I have posted screenshots above, showing how the app is making requests every single time I refresh/relog to retrieve the data from the moralis server and how it is no longer doing that, once I build it.
And its not only on refresh
if I change the network, state gets updated, but its still not even trying to retrieve my balance from the new chain.
There are no errors, I have wrapped every single async function in a try/catch
block, logging the errors, but there is nothing.
So if I have issues with wrapping, or some fundamental setup of Moralis, wouldnt that make it not work in dev mode too?
So what am I doing wrong?
P.S. Merry Christmas!