Fix guides / 404 or blank page when you refresh a sub-page
Your app works until you refresh: fixing 404s and blank pages on sub-pages
The home page loads and navigation works. But refresh on /dashboard, or open a link someone shared, and you get a 404 Not Found or a blank white page. This is the most common deploy problem for Vite and React apps from Lovable, Bolt, and similar tools.
Why it happens
Your app is a single-page app (SPA). There is only one real HTML file, index.html. When you click a link, React Router changes the URL in the browser without asking the server for anything. When you refresh, the browser asks the server for /dashboard, and the server has no file by that name, so it returns a 404.
The fix is to tell your host: "for any path you do not recognize, serve index.html and let the app decide." This is called an SPA fallback or rewrite.
Netlify
Create a file named _redirects in your public folder (so it ends up in the build output) with one line:
/* /index.html 200
Vercel
Add a vercel.json at the project root:
{
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}
Vercel serves real files (like your JavaScript and images) before applying the rewrite, so assets keep working.
Cloudflare Pages
Cloudflare Pages treats a project as an SPA automatically when there is no top-level 404.html in the build output. If you added a 404.html, remove it, or add a _redirects file with /* /index.html 200.
Still a blank page, even on the home page?
- Wrong output folder. Vite builds into
dist; Create React App builds intobuild. Your host's output directory setting must match. - Wrong base path. If the site lives in a subfolder (for example GitHub Pages at
/my-app/), setbase: '/my-app/'invite.config.ts. Otherwise script tags point at the wrong place. Open the browser console: 404 errors on.jsfiles confirm this. - A JavaScript error on startup. Open the console. A missing environment variable (for example
supabaseUrl is required) crashes the app before anything renders. See our guide on environment variables.
How to verify
Deploy, open your site in a private window, go directly to a deep link like /settings, and refresh twice. It should load every time.
Request a fix
Last updated 2026-10-19.