All posts

Your AI-built app works in the editor but breaks live: 8 causes

Your app works in the builder's preview or on your own computer. Then you deploy it, and something is broken. A blank page. A login that fails. Data that never loads. A page that gives a 404 when you refresh. Images that are missing. This happens a lot with apps from Lovable, Bolt, Cursor and Replit, and it is almost always one of a short list of causes. Vendor facts below come from each vendor's own docs, checked in November 2026.

Short answer: the editor and the live site are two different places. They have different addresses, different settings and a different build step. Your app was only ever tested in the first one. Open the browser console first, then the Network tab, then the host's deploy log. Those three tell you which of the eight causes below you have. Work through them in order and change one thing at a time.

1. Environment variables are missing on the host

Symptom: blank page, "undefined" in the console, or data calls that fail with an authorization error. The app worked locally because a .env file on your computer held the values. That file usually is not uploaded, and it should not be.

Confirm it: open the host's settings (Netlify: site settings, environment variables. Vercel: project settings, environment variables). Compare the names with your local .env file. Any name that is in the file but not on the host is a suspect. Then look at the spelling. Vite's env docs say: "Variables prefixed with VITE_ will be exposed in client-side source code after Vite bundling." So a browser variable named SUPABASE_URL without the prefix will be undefined in the browser, even if you set it on the host.

Fix: add each missing variable on the host, with the exact same name. Then redeploy. This step is easy to forget. The same Vite docs say the values "are bundled into your source code at build time." Vercel's environment variable docs say: "Any change you make to environment variables are not applied to previous deployments, they only apply to new deployments." Netlify's build variable docs say its variables are "accessible during your build". So on both hosts, treat a changed value as a reason to build again.

One warning: Vite also says VITE_* variables "should not contain sensitive information such as API keys". Anyone can read them in the public JavaScript. If your secret key has a VITE_ name, read the API key check before you do anything else.

2. API URLs still point at localhost or the builder's preview

Symptom: the page loads, but lists and forms stay empty or show an error. Often it works on your computer only.

Confirm it: open the browser developer tools, then the Network tab, then reload. Look for red requests. Click one and read the address. If it starts with http://localhost, or with the address of the builder's preview, you found it. Visitors' browsers cannot reach your laptop, and a preview address may be switched off or changed.

Fix: put the address in one environment variable, such as VITE_API_URL, and set the live value on the host (see cause 1). Then redeploy. Prompt for your AI tool: "Search the whole project for localhost, 127.0.0.1 and the preview domain. Replace each hard-coded address with an environment variable. List every file you changed." If you also have a separate test database, see staging copies and preview databases so the live site does not write into test data.

3. Refresh or a direct link gives a 404

Symptom: the home page works. You click around, and it works. You press refresh on /pricing, or open a shared link, and you get a 404 page from the host.

Why: most AI-built front ends are single-page apps. There is only one real file, index.html. The app draws the other pages in the browser. The host looks for a file called /pricing, finds nothing and says 404.

Confirm it: open a deep link in a new tab. If the host's own 404 page shows up, and the console is empty, this is it.

Fix on Netlify: add a rewrite rule. Netlify's rewrites docs show this line for a _redirects file in your publish folder: /* /index.html 200. The netlify.toml version is a [[redirects]] block with from = "/*", to = "/index.html" and status = 200. Netlify says it will "effectively serve the index.html instead of giving a 404 no matter what URL the browser requests."

Fix on Vercel: Vercel's vercel.json docs show a rewrite for single-page apps: "rewrites": [{ "source": "/(.*)", "destination": "/index.html" }].

One note: a real 404 page for URLs that truly do not exist is still good for visitors, so ask your AI tool to add a "not found" page inside the app. Also, single-page apps have limits with search engines, see why Google may not see your pages.

4. File names with the wrong upper or lower case

Symptom: the build fails on the host with "Could not resolve" or "Module not found", but works on your computer. Or images are missing live.

Why: your computer may treat Header.vue and header.vue as the same file. The build server may not. Netlify's troubleshooting tips say the Netlify build "may fail as the file system used in Netlify builds is case sensitive while your build environment is not." It adds that the error messages "may not clearly indicate this".

Confirm it: read the deploy log. Find the first error line and the file name in it. Compare the spelling and the capital letters with the import and with the real file on disk. For example, ./Components/Header against a folder called components.

Fix: make the import and the real file name match exactly, including capitals. The same Netlify page warns that on a case-insensitive computer, renaming a file and committing may not register in Git. You may need git mv to change the case. If that sounds hard, ask your AI tool: "Find every import and image path where the letter case does not match the real file name. Fix them and use git mv for renames."

5. The build differs from the dev server

Symptom: everything works while you run the dev server. The deploy fails, or the live site is blank.

Why: the dev server is forgiving. The production build is stricter, and it bundles and shrinks your code. Some mistakes only show up there.

Confirm it: run the real build on your computer. Vite's deployment guide says: "You may run npm run build command to build the app." Then run npm run preview. Vite describes it as "an easy way to check if the production build looks OK in your local environment." Open the address it prints (by default http://localhost:4173) and look at the console. If it breaks here, it will break live. Vite also notes that vite preview is "not meant as a production server", so use it for checking only.

Fix: read the first error, not the last. Copy it to your AI tool with the file name. If the build passes locally but fails on the host, open the host's deploy log and compare the Node version and the build command with your local ones. Do the same checks again after each change.

6. Mixed content: an https page calls an http address

Symptom: data does not load on the live site. The console says "Mixed Content" and that the request was blocked.

Why: your live site runs on https. Somewhere in the code, an address starts with http://. MDN's mixed content page says browsers "block insecure requests for all other resource types", after auto-upgrading images, video and audio. It lists fetch() requests among the blocked kinds.

Confirm it: in the console, look for the word "Mixed Content". In the Network tab, a blocked request shows the http:// address in red.

Fix: change the address to https://. If the other service does not offer https at all, call it from a server function you control instead of from the browser. Prompt: "Find every http:// address in this project and switch it to https. Tell me if any service does not support https."

7. The sign-in service does not know your live domain

Symptom: login works on localhost. On the live site you get an error, a redirect back to localhost, or a loop. Email links for "confirm email" or "reset password" open the wrong address.

Supabase: the redirect URL docs say the Site URL "defines the default redirect URL when no redirectTo is specified in the code." It defaults to http://localhost:3000, and the docs say to change it "to your production URL." They also say a redirectTo value "should match the Redirect URLs list configuration". In the dashboard, open Authentication, then URL Configuration, and check both.

Firebase: Firebase's Google sign-in guide talks about adding your domain "to the list of authorized domains in the Firebase console" when you use a custom domain. Open Authentication settings in the console and check that your live domain is on that list. Include the www version if you use it.

Confirm it: try to sign in on the live site. Read the address bar after the redirect, and the console message. Then compare the live domain with the list in your auth settings, letter by letter. Social buttons have their own redirect list at Google or Apple too, see what breaks with social sign-in.

8. CORS on the live address

Symptom: the console says "blocked by CORS policy". It only happens on the live domain, because your server only allows the old address. A short version: the browser asks the other server "is this page allowed to read your answer?", and the answer is no. The fix is on the server side, not in the browser. See the full CORS guide for the steps per platform.

The 10-minute diagnostic order

  1. Open the live site in a private window. Open developer tools, then the Console tab. Reload. Copy the first red error.
  2. Open the Network tab and reload. Sort by status. Click the first red request and read its address and status. A localhost address means cause 2. A blocked http address means cause 6. A CORS message means cause 8.
  3. If the page itself is a host 404 on refresh, go to cause 3.
  4. If the deploy failed, open the host's deploy log. Read the first error. A missing file means cause 4. Anything else, try cause 5 on your computer.
  5. Compare the host's environment variables with your local .env file. Check names and the VITE_ prefix (cause 1).
  6. If the problem is login only, check the auth service's Site URL, Redirect URLs or authorized domains (cause 7).
  7. Change one thing. Redeploy. Test again on the live site. Do not stack several changes.
  8. Still stuck? Roll back to the last working deploy, so visitors are fine while you look. See how to roll back a broken deploy.

Example prompts for your AI tool

  • "This is the console error from the live site: [paste]. Which file and line does it come from? Explain the cause in plain words before you change code."
  • "List every environment variable this project reads. Mark which are used in the browser and which on the server. Tell me which names need the VITE_ prefix."
  • "Add a rewrite so every path returns index.html with status 200 on Netlify. Show me the file you change."
  • "Run npm run build and fix every error. Then tell me what npm run preview shows."
  • "List every place the live domain must be added: auth redirect URLs, allowed origins and email templates."

If you are moving the app between tools, moving a Lovable or Bolt app to your own hosting shows which settings do not travel with the code.

Checklist

  • The first console error is copied, with the failing address.
  • Every variable from .env exists on the host, with the same name.
  • Browser variables start with VITE_, and none holds a secret.
  • The app was redeployed after the last variable change.
  • No localhost or preview address is left in the code.
  • A rewrite to index.html is in place, and refresh works on a deep link.
  • Import paths and file names match in upper and lower case.
  • npm run build and npm run preview work on your computer.
  • No http:// address is called from the https site.
  • The live domain, with and without www, is in the auth settings.
  • CORS allows the live origin.
  • Tested on the live domain, in a private window, on a phone too.

Want this fixed for you?

I finish and fix apps built with Lovable, Bolt, Cursor or Replit, including apps that work in the editor but break on the live site. Send me the details and I'll reply within 24 hours.