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-passwordor any nested route directly causes a Vercel404error. - 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.
vite.config.ts
export default defineConfig(({ mode }) => ({ base: '/', server: { host: "::", port: 8080, }, plugins: [react()], resolve: { alias: { "@": path.resolve(__dirname, "./src"), }, },}));vercel.json
{ "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]}Steps to reproduce:
- Deploy to Vercel
- Visit
https://your-production-domain/reset-password→ ❌ 404 - Visit
https://your-production-domain/sub-route/:param→ ❌ 404 - These same URLs work in dev and preview
Project Info
- Framework: React (TypeScript) + Vite
- Router: React Router DOM (
createBrowserRouter) - Hosting: Vercel (Preview works fine, Production has issue)
- Auth: Supabase (sends email reset-password links to frontend)
- Deployment: Auto from GitHub


