Blog · 2026-11-13
Why a Lovable or Bolt app works when you click, but 404s on refresh
A Lovable 404 on refresh usually means the host has no fallback to index.html. Here is how to reproduce it, and the official rewrite rules for Netlify, Vercel, Firebase, and Cloudflare Pages.
You click from the home page to /dashboard (or /app, /pricing, /login). The screen looks fine. Then you refresh, or you paste that URL into a new tab, or you share the link. The host answers with a 404.
That Lovable 404 on refresh is usually not a missing React or Vue route. The client-side router already knows the path. The server never got a chance to hand the request back to your app.
This shows up a lot on apps shipped from Lovable, Bolt, v0, or Cursor and then published as a static single-page app (SPA). The same thing happens on any host that only serves files that actually exist on disk.
What the visitor actually sees
On the home page, everything seems to work. Clicks use the in-app router: the browser changes the path with the History API (pushState) and your JavaScript draws the next screen. No new document is requested from the server.
A refresh is different. The browser asks the host for that exact path, for example GET /dashboard. If the publish folder has no dashboard.html or dashboard/index.html, and the host has no fallback rule, the server correctly returns 404.
Shared links, bookmarks, email CTAs, and “open in a new tab” fail the same way. People who arrived through your menu never notice. People who arrive on a deep link do.
Why it happens: client-side routes and a missing rewrite
Lovable, Bolt, and similar builders often output a static SPA: one index.html, a JavaScript bundle, and assets. The router lives in the browser. Paths such as /dashboard are not real files. They are instructions for the app after index.html has loaded.
For a refresh or a direct visit to work, the host must do this:
- If the request matches a real file (a script, an image, a CSS file, a static page), serve that file.
- If it does not, serve
index.htmlwith HTTP 200, without changing the URL in the address bar. - The app boots, reads
window.location, and renders the right screen. If the path is unknown to the router, the app can show its own “not found” view.
That second step is a rewrite (sometimes called a fallback). It is not a redirect. A 301 or 302 to / would load the app, but it would also wipe the path, so the router would open the home page instead of /dashboard.
If you skip the rewrite, you get a Lovable 404 on refresh even when every in-app click still works.
How to reproduce it in about 30 seconds
- Open the live app in a private window and wait until the home page is fully loaded.
- Click through to an inner route. Confirm the URL bar now shows something other than
/— for example/dashboardor/app. - Copy that full URL.
- Paste it into the same window’s address bar and press Enter, or refresh the page, or open the URL in a new tab.
If the home page still works but this request 404s, you are looking at a missing fallback, not a broken button. If even in-app clicks 404, you may have a different problem (a bad link, a failed deploy, or a route the app does not define).
How to fix it on common hosts
Add a catch-all rewrite to index.html on the host that actually serves the built files. Put the rule last if you also have more specific redirects. Existing static files should still be served first (that is the default on the hosts below, unless you force the rule).
Syntax below is taken from each host’s official documentation. Check the current docs before you ship, and confirm the file sits in the published output, not only in the project root if your build does not copy it.
Netlify
Use a _redirects file in the publish directory, with status 200 so it is a rewrite, not a redirect. Netlify documents this for History pushState and single-page apps, and recommends making it the last rule if you have others:
/* /index.html 200The same rule in netlify.toml:
[[redirects]]
from = "/*"
to = "/index.html"
status = 200By default Netlify will still serve a real file when one exists at that path (“shadowing”). Only add 200! (or force = true) if you intentionally want to ignore a matching file. Official docs: Rewrites and proxies.
Vercel
In vercel.json, Vercel documents this pattern as the usual SPA rewrite. Rewrites run after the filesystem, so existing static files keep precedence:
{
"$schema": "https://openapi.vercel.sh/vercel.json",
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}Official docs: Static Configuration with vercel.json and Rewrites on Vercel.
Firebase Hosting
In firebase.json, under hosting. Firebase only applies a rewrite when no file or directory already exists at that path:
{
"hosting": {
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}Official docs: Configure Hosting behavior.
Cloudflare Pages
If the project has no top-level 404.html, Cloudflare Pages already treats the deploy as an SPA: unmatched paths are served from the root /, so the client-side router can handle them. That is the default documented behavior.
If you do have a 404.html, or you want an explicit fallback, Cloudflare Pages supports proxy (rewrite) rules in _redirects with status 200:
/* /index.html 200Official docs: Serving Pages (SPA rendering) and Redirects (proxying).
nginx
On a server you control, official nginx docs describe try_files as checking files in order and, if none exist, performing an internal redirect to the last URI. For an SPA that last URI is /index.html:
location / {
try_files $uri $uri/ /index.html;
}Official reference: Module ngx_http_core_module (`try_files`) and Serving static content.
After you add the rule
Publish again, then repeat the 30-second check. The deep link should load with HTTP 200 and show the inner screen, not the home page and not a host 404. A typo in a path that the app does not define should now show your in-app not-found view, still with a 200 from the host.
What else to check before you launch
A working fallback does not mean the app is ready. After the rewrite is in place, walk the live URL as a first-time visitor would:
- Broken links and images on the first page.
- Buttons that do nothing.
- Layout that breaks on a phone.
- Sign-up, before real users try it.
If you want a second pass, paste the public URL into the free TestMyLaunch check. A real browser opens the app on a phone and a desktop, follows links, and returns a score with the titles of what broke.
FAQ
Why does a Lovable 404 on refresh happen when every click still works?
Clicks are handled in the browser by the client-side router. A refresh asks the host for a file at that path. If the host has no rewrite to index.html, it returns 404.
Is this a bug in my dashboard route?
Not necessarily. If in-app navigation to /dashboard works, the route exists in the app. The missing piece is usually the host fallback. If the route also fails when you click, fix the app route or the link first.
Should I use a redirect to / instead of a rewrite?
No. A redirect changes the URL. The visitor would land on the home page and lose the deep link. Use a rewrite that keeps the path and returns index.html with 200.
Will this hide real 404s for missing images or scripts?
A catch-all fallback can serve index.html for any unmatched path, including a typo in an asset URL. The hosts above still serve a real file when one exists. For asset folders, prefer exact files and let missing assets 404 where the host allows a more specific rule. Unknown app routes should be handled by your router after index.html loads.
I custom-domain my Lovable or Bolt app. Where do I put the rule?
On the host that serves the production files for that domain (for example Netlify, Vercel, Firebase, Cloudflare Pages, or nginx). A rewrite in a repo that is never published will not change the live site. If the app is still on the builder’s default host, check that host’s own publish settings; do not assume a _redirects file is read there unless their docs say so.
Does a 200 on /dashboard mean the page is correct?
It means the host gave the app a chance to boot. You still need to confirm the screen is the one you expect, and that buttons, links, and the phone layout work.
TestMyLaunch checks a public app in a real browser, on phone and desktop. The free check shows a score out of 100 and the titles of the problems it found. [Check your app](https://testmylaunch.com).