When I visit my website I cannot reload it

@murtazanaqvicoder Ah, I’ve run into this before with Vite projects. The issue is with React Router. Vite produces an SPA by default, and React Router just uses techniques like history.pushState for routing.

So you need all routes to redirect to the root SPA file (index.html), which you can do with a vercel.json config file in the root of your project:

{
  "rewrites": [
    {
      "source": "/(.*)",
      "destination": "/index.html"
    }
  ]
}

I have a demo of the fixed site here, which I will remove later to keep my account clean:

Let me know how it works!

3 Likes