React App working on localhost but not working on Netlify deploy because the API call is different

I am developing a React app using freetogame API and it works perfectly on localhost, but I deployed it on Netlify and it’s not working because it’s making the API call to a different adress. Here is the API call on localhost:localhost API Call

and here is the API call on the deployed site: Deployed Site API Call

As you can see in the deployed site API call, the Request URL is completely different and there is an /undefined/ part in the Request URL in the API call. I don’t know what’s causing this problem. Here is the Github link to the project: Project Github Link and here is the deployed site link: Deployed Site Link

Also, I added my environment variables to Netlify, but I didn’t added baseURL, headers and params I use on my Axios Call. Is this what’s causing the problem, and if it’s how can I add them? Here is my Axios Call: Axios Call

and here is my package.json file: package.json

Please help me find a solution. Thanks in advance.

I found a solution and wanted to post it here so it can help others. I tried deploying my build file to Netlify manuelly and the site is working now.

Hi I’m new here how to find the solution?

@Latifa-Sikder-Bristy, you will find a solution if you post your problem.

1 Like