Cors problem nextJs / moralis 1.11.0

I have a problem after installing latest version of Moralis (version 1.11.0).

When calling functions like fetchERC20Balances from useERC20Balances, I get Cors errors (access to XMLHttpRequest from origin localhost has been blocked by CORS policy…):

I tried to reinstall Moralis version 1.10.1 and it works. So the problem is due to 1.11.0

I’m using nextJs latest version. I’ve read about webpack5 problems, but nextjs 12 doesn’t allow to use webpack4. I wasn’t able to fix the problem as suggested on the site.

I’m telling this because maybe the problem is related to it. But everything was good before version 1.11.0

How can I solve the problem? I would be glad if someone who solved webpack5 issue can show what to put in next.config.js

Also, I really want to use last Moralis version, but need to solve Cors problems.

Thank you! :smile:

Hi can you try updating your Moralis server if your server is not on the latest version (v0.0.383).


Perfect! It works now, thank you! :slight_smile:
Could you also tell me how to implement webpack5 on NextJs to avoid issues in future? As I said I’ve read the fallback to implement on the site, but I don’t know how to do it!

The latest Next.js is already on webpack 5. If you have issues with Moralis or react-moralis with your Next.js app then you can make another topic/thread.

1 Like