Surge-deployed React app - getting 404 Page Not Found

You can't access your routes directly. you have to do this little hack for that.

  1. After you run the npm run build command you have to go to the build folder of your react application folder.
  2. Take a copy of index.html file. then past it in the same place and rename it as 200.html now it will work as we wish. This is all for today.

read more about this issue: here


Change your build step in package.json

"build": "react-scripts build && cp build/index.html build/200.html"

Source: https://medium.com/superhighfives/serving-client-side-routing-with-surge-sh-7b705542cf3


Follow below step to resolve(only 4 surge):

  1. npm run build
  2. cd build
  3. cp index.html 200.html
  4. surge

From here you can continue as usual