DEV Community

Abdulrazaq Salihu
Abdulrazaq Salihu

Posted on

How to fix React/Vite redirect issue in Vercel

If you're experiencing redirect issues when deploying your React application with React Router on Vercel, there are a few common solutions you can try:

Vercel supports a redirect configuration file called vercel.json. In your project's root directory, create a file named vercel.json and add the following line to it:

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

This rule tells Vercel to redirect any request to the index.html file, which is the entry point of your React application.

After applying this solutions, rebuild your React application (npm run build) and redeploy it to Vercel. The redirect issue should be resolved, and your application's routing should work as expected.

Top comments (0)