How to fix React/Vite redirect issue in Vercel
Abdulrazaq Salihu

Abdulrazaq Salihu @abdrzqsalihu

About: Software Developer with experience in building and maintaining responsive websites and applications. 👨🏽‍💻

Location:
Abuja, Nigeria
Joined:
Jul 17, 2021

How to fix React/Vite redirect issue in Vercel

Publish Date: May 30 '23
5 0

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.

Comments 0 total

    Add comment