Fix 404 on page refresh after moving a Lovable or Bolt app to Vercel or Netlify
Updated
404: NOT_FOUND (on refresh or when opening a link to an inner page)A React and Vite single-page app has one index.html, and its routes exist only in the browser. When you reload /pricing, the host looks for a pricing file, finds nothing and returns 404. Tell the host to serve index.html for every path: a rewrite in vercel.json, a _redirects file on Netlify, or try_files on Nginx. This applies to older Lovable projects and Bolt’s default template; new Lovable projects on TanStack Start render on the server and don’t need it.
Vercel
Create vercel.json in the project root:
{
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}Netlify
Create public/_redirects, so Vite copies it into the build:
/* /index.html 200Nginx
location / {
try_files $uri $uri/ /index.html;
}What this doesn’t fix
The 404 goes away, but every URL still returns the same nearly empty HTML. Search engines and AI assistants see one blank page, and link previews show the same title everywhere. If those pages need to be found, see the guide on search visibility.
Also make sure a missing page in your app shows a real “not found” screen. With the rewrite, the host returns 200 for any address.