reactjsdeploymentnetlifyportfolio

trouble deploying react app through netlify


Hello I've recently completed an SEI bootcamp and am in the process of trying to deploy my portfolio, which is a react app. I've used heroku in the past but seeing as how I've reached my limit with them and wanting to try a new deployment method I've decided to use netlify.

Right away I tried doing this through netlify's site by linking up my github and selecting the repo I wanted. It seemed to go fine and I purchased a URL via netlify but when I went to what was my sites page I was getting a "404 error page not found".

After some research I tried adding a "_redirects" file into my root and also tried to add it into my public directory inside my client(react) dir and added in the line of code netlify suggests in their docs.

This of course didn't solve it. One thing I noticed was that I was able to add in a blank index.html in my root and just write 'hello' in it and that appeared on my site.

I haven't been able to find another solution or fix. I tried something similar to how I would deploy with heroku which was to restructure my files and essentially take everything from the client directory and moved it into the root directory of my project.

This didn't solve the 404 error, or not being able to display my react app.

A friend from my cohort told me he was able to deploy via the CLI instead of doing it directly from netlifys site, so I tried it like this still using the restructured file set up.

Im at a loss at the moment, any help is greatly appreciated.

Thanks


Solution

  • Try adding a netlify.toml file to your repo and add this inside this.

    [[redirects]]
      from = "/*"
      to = "/index.html"
      status = 200