Hi all,
I'm deploying a React + Vite SPA to Vercel (not using Next.js), and I’m seeing Vercel’s default 404 page on client-side routes like /profile, even though the root (/) loads correctly.
What I’ve Tried:
- Rewrite to
/index.htmlinvercel.json - Ensured
vite.config.jsincludesbase: '/' - Removed
frameworkfield fromvercel.json - Set project preset to
"Other"in Vercel - Cleared cache and redeployed multiple times
- Confirmed the route works locally with
npx serve dist index.htmlis present and served for root/
What’s Happening:
- SPA routes like
/profilereturn Vercel's generic 404 - Vercel appears to ignore the rewrite rule in
vercel.json - The app never loads → React Router never takes over
I believe this may be a deeper issue with how rewrites are applied to non-Next.js frameworks, or potentially a conflict with internal defaults.
Appreciate any help or confirmation from the Vercel team 🙏
- Live App: https://stagelocate.com
- Failing Route: https://stagelocate.com/profile
- Framework Preset: "Other" (set in dashboard)
- Build Output:
dist/ - Vite Config:
base: '/', clean asset paths
vercel.json:
{ "version": 2, "buildCommand": "npm run build", "outputDirectory": "dist", "rewrites": [ { "source": "/(.)", "destination": "/index.html" } ], "headers": [ { "source": "/(.)", "headers": [ { "key": "X-Content-Type-Options", "value": "nosniff" }, { "key": "X-Frame-Options", "value": "DENY" }, { "key": "Strict-Transport-Security", "value": "max-age=31536000; includeSubDomains" } ] } ], "cleanUrls": true, "trailingSlash": false }
vite.config.js:
export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ""); return { base: "/", build: { outDir: "dist" }, plugins: [react()], server: { port: 8080 }, }; });