@mukwende2000
Posted
when i deployed my first site on vercel, i had the same issue, getting an error on refresh, the issue is that react is a client side library and all the routes are being fetched from the client, so when you first visit a route for the first time, it loads it as it is loaded by the client, but when you refresh, the browser tries to fetch it from server but finds no such routes, so it throws a 404. To solve it on vercel, we have to set it up in the vercel.json file such that no matter which route we are on, it serves only the index.html. Remember that is the only page in the application, no wonder its a single page app, so you have to find out how to do it on github pages. Hope that makes sense and hopt you go find out and not leave that way.
Marked as helpful