0

I am new to vercel, I built a small web application in react. And I deploy my application in vercel. It was successfully deployed and works fine. in my scenario, I'm using React-router and it works fine while I'm clicking on link buttons, but when I refresh my webpage or write manually it does not load. It threw the 404: NOT_FOUND error. But the hard refresh only works fine in my base URL.

This only happened to the deployed server, not the local server.

I don't know what to do

Gibson
  • 82
  • 7
  • Welcome to Stack Overflow . Please provide your code, along with error and your expected result please provide a [minimum reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) See [How do I ask?](https://stackoverflow.com/help/how-to-ask) – Shivam Jha Feb 26 '23 at 12:31
  • @Gibson, Did you deploy built static js code on the server? If so, it's natural it throws that error because server doesn't recognize urls except home url. To solve this issue, you an rewrite all the paths to the home url with vercel.json file. You can reference this https://stackoverflow.com/questions/64815012/why-does-react-router-not-works-at-vercel – Meerkat Feb 26 '23 at 13:55

1 Answers1

0

In your package.json change

"private": true, to "homepage": ".",

Ben
  • 9
  • 2