SPA 404 on refresh: Vercel, Netlify, Cloudflare Pages
On Vercel this shows as the NOT_FOUND error. The host looks for a file at /dashboard, finds none, and returns 404 because routing happens in the browser. Add a rewrite that serves /index.html for unknown paths: vercel.json rewrites on Vercel, a _redirects rule on Netlify, and on Cloudflare Pages remove any top-level 404.html.
Cause: No SPA fallback rewrite to index.html is configured on the host.
How to fix it
- Vercel: add a catch-all rewrite to
/index.htmlinvercel.json. - Netlify: add
/* /index.html 200topublic/_redirects. - Cloudflare Pages: SPA fallback is the default unless a top-level
404.htmlexists; remove it or add a_redirectsrule. - Redeploy and test a deep link in a fresh tab.
Example
Illustrative example, not from a customer project.
+ // vercel.json
+ { "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }] }
+ # public/_redirects (Netlify)
+ /* /index.html 200
FAQ
Why does the home page work?
/ maps to index.html; only deep links need the fallback.
Will the rewrite break my API routes?
Order matters: put API routes or functions before the catch-all.
QUICK FIX · $49 · THIS ERROR ONLY
Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis
- Fixed, or we keep working free until it is (within the written scope).
- A human reviews every fix before it ships.
- Read-only access; fixes arrive as pull requests you merge.
- Your $149 diagnosis is credited in full toward any paid job.
One error, one root cause, fixed in your app. If it turns out bigger, we tell you before doing more, and your $49 is credited toward the fix, diagnosis or Launch Path if you book within 14 days. Fixing three? The 3-Error Pack is $119.
Bigger job: Getting the whole app live? Launch Path, $1,195 flat.
Built with Lovable, Bolt, Replit, Cursor or v0? See rescue by platform and the security checklist.