[Problem Solved] Axios.get works on localhost but doesnt work after deploying on Netlify No data from database is shown

This is my Netlify site

I hosted the backend on Heroku using ClearDB for MySQL. Sometimes, the Heroku database has connection error but I tested it when it is fine.
Let me know if there are Heroku application error when you are testing it.

It was able to show all the product data from the database on localhost through Axios.get. However, it cannot show anything after deploying on Netlify.

Following is the react code of this page:

You have CORS errors.


You need to setup the Access-Control-Allow-Origin header on Heroku.

Oh, Thank you so much. I forgot to check F12 on the browser.
I solved this error. I forgot to use cors package in my backend.

I deleted the following code in my last test. I realized you also need to add this in your server.js
image

1 Like