How to switch environment in SDK?

So to setup the moralis server in SDK, we are doing ā€œMoralis.start(SERVER_INFO)ā€, thing is we want to have multiple environments, so both ā€œtestnetā€ and ā€œmainnetā€ in the same app - bad planning and we add it to an existing infrastructure that doesn’t allow us to have 2 different domains for these…

So I’m asking, if I can do Moralis.start(), is there a Moralis.stop() somewhere? or Moralis.switchServer() or something of the like?

I found an undocumented ā€œcleanup: () => Promise;ā€ function, which seems to work? but I’m not sure if that’s the right thing to use…

I’m thinking that you can do some kind of initial initialisation of the app with one of the two, and you restart the app when you want to change the environment

1 Like