In my React + Vite project using createBrowserRouter, everything works as expected in local dev and Vercel preview deployments. But in production, routes like /reset-password and nested paths like /users/:id throw a 404 error when accessed directly or refreshed.
Current (Production only):
Visiting /reset-password or any nested route directly causes a Vercel 404 error.
Supabase password reset link (which redirects to /reset-password) fails in production.
Expected:
These routes should be handled by the SPA (index.html) and routed correctly by React Router.
Hello Jacob. I am having the same issue with getting 404 when I refresh my nested routes. I went to your live site in your github readme. I am seeing 404 error when refreshing a nested route on your live site. https://vite-react-drab-two-60.vercel.app/
@kjasmita-microbinio I find it very interesting that it works in preview but not production. Do you have the source code (or a minimal source code with the same error) public anywhere so I can test it?
@bestcodes i added the vercel.json file to the root but it is not fixing the 404 error. Here is my project if you would like to check it out. GitHub - JacobBaqleh1/ROAM
Edit: This response is not applicable to you, ignore it!
Response
@jacobbaqleh1 Odd that you are still having issues, since my demo deployment is working fine. Have you modified any of the project settings on the Vercel deployment? Mine look like this:
@jacobbaqleh1 I actually think it’s an issue with your setup. Your vercel.json should be in your project root. If you are deploying Develop the folder as the project and using the client subdir for the build output, that isn’t going to find your vercel.json.
Do not put the vercel.json in the GitHub project root. If you do, you will see a warning:
“Provided root directory” means the project root you set in settings on vercel.com, which you should set to Develop/client.
Based on your current project config, you should move vercel.json from Develop/client to Develop/. Do not move it to the GitHub project root, just to Develop/, which is the deployment root.