0
votes

I'm completely new in React world.

A few days ago I developed my very first simple React app, built the app and uploaded it to my GoDaddy host. I thought this would be enough as I had an index.html in the root of my host and the thought that the build will work once I open my domain in browser.

Unfortunately, it turned out that it's not working. Nothing is easy in life.

enter image description here

After hours of googling I found out that people upload their React apps to special services such as Heroku. I found a tutorial and managed to publish my react app successfully on Heroku. But to be honest I still don't know why my app wasn't working on GoDaddy server.

When I was preparing my app for Heroku, one step was creating a server.js file using express.js.

Does it mean that each React app needs such a server file to be working? What if I wanted to use my React app on GoDaddy or any other hosting server? Would it be possible?

1
Does the application have a dependency to Node.js? Or did you build it so that it can be served independently? - Andreas
React app don't any server file you just need a to deploy your server on somewhere and can use this server into your app. - Waheed Akhtar
@Andreas, It's just a simple journey planner app that sends an API request to TFL (Transport for London) and prints the result in to UI. - user1941537
@Waheed, sorry, but I don't understand. You say that React apps don't need any server file. But then you add "you need to deploy your server on somewhere". Now I'm confused. - user1941537
@user1941537 do you know about axios? - Waheed Akhtar

1 Answers

1
votes

OK, I found out what was the problem.

It turned out that paths inside the index.html don't mirror the build folder structure.

Inside the index.html I had to change references like this:

/static/css/2.567.chunk.css

To this:

./static/css/2.567.chunk.css

And inside of CSS files I needed to change paths like this:

/static/media/tree.6098.jpg

To this:

../media/tree.6098.jpg

After that you simply upload your files and everything works as it should.

Now the question is, why those paths are not as they should be?