Blank white page after publishing your AI-built app
Updated · by Zane
Why the page is blank
These apps run in the browser. The page loads a script, and the script draws the screen. If that script throws an error while starting, nothing is drawn and you get a white page with no message.
A blank page tells you nothing about the reason. The browser does, but only in a place most people never open.
Step 1: open the console
- Open your live address in the browser.
- Press F12. On a Mac, press Cmd+Option+J.
- Click the Console tab and find the first red error. Later errors are often just fallout from the first.
- Click the Network tab and reload. Look for any
.jsor.cssfile shown in red with a 404.
What you find points to one of four cases.
Case 1: a missing environment variable
In my demo project I removed VITE_SUPABASE_URL from the production build. The build still succeeded, and the published page was blank. The console showed this, which is the supabase-js library's own message:
supabaseUrl is required.The code that creates the Supabase client reads two values:
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL as string;
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY as string;
export const supabase = createClient(supabaseUrl, supabaseAnonKey);If either value is undefined, creating the client throws at startup, and the whole app fails with it. Your own error may name a different key. Any message saying a key or URL is required or undefined is the same kind of problem.
What to check
- In a Vite project, only variables with the
VITE_prefix are included in the frontend code. - The name must match the code exactly, including capitals.
VITE_SUPABASE_URLandVITE_Supabase_Urlare different variables. - These values are written in at build time. After adding or changing one on your hosting platform, you must rebuild and redeploy. Saving it is not enough.
- On most platforms, preview and production variables are set separately. A value in one does not carry over to the other.
The same rebuild rule matters when you switch Stripe keys for going live. The guide on test and live mode covers that.
Case 2: a 404 on a script or stylesheet
If Network shows a missing .js or .css file, the page cannot find its own code. The usual causes:
- The site lives under a sub-path, such as
yourdomain.com/app/, and the build was not told. In Vite this is thebasesetting. - Your domain still points to an older deployment whose files no longer exist.
Compare the file name in the failing request with the files your latest deployment actually contains. If they differ, the domain is serving something old.
Case 3: the home page works, inner pages do not
If the home page loads but opening or refreshing /dashboard gives a 404 or a white page, your hosting does not know that every path should return the same index.html. Apps like this handle routes in the browser, so the server must send the main file for any address.
- Netlify: add a file named
_redirectsin the public folder with the line below. - Vercel: add a
vercel.jsonwith a rewrite, shown below. - Cloudflare Pages: a project without a
404.htmlfalls back to the single-page app by default.
/* /index.html 200{
"rewrites": [{ "source": "/(.*)", "destination": "/index.html" }]
}Case 4: CORS or 401 errors in the console
If the red error mentions CORS or a 401, the page loaded but the backend refused it. The usual cause is that the backend only allows your preview address. Add the live domain to its allowed list. If the problem is specifically about signing in, see login sending users to localhost after publishing.
A security warning about VITE_ variables
Everything with a VITE_ prefix is copied into the code that every visitor downloads. That is fine for values meant to be public: the Supabase anon or publishable key, and the Stripe publishable key. Never give that prefix to a service role key or a Stripe secret key. Anyone can open the page code and read them. Public keys are safe only when your table rules are right, which is what the two-minute RLS check is for.
Test the fix
- Redeploy after changing any variable.
- Open the live site in a private window so no cached copy is used.
- Check that the console has no red errors.
- Open an inner page directly, then refresh it.
The second video on the home page shows this kind of fix, from a failing deploy to a working launch on a custom domain.
FAQ
Why did it work in preview?
The preview environment usually has its own variables set already. The published site is built separately, and if a variable was never added there, the code starts with an undefined value and crashes before drawing anything.
I added the variable and it is still blank.
Variables with the VITE_ prefix are written into the code when the site is built. Saving the variable does not change a site that was already built. Trigger a new build and deploy, then open the site in a private window to avoid a cached copy.
Is it safe to put my keys in VITE_ variables?
Only the ones that are meant to be public: the Supabase anon or publishable key and the Stripe publishable key. Anything with a VITE_ prefix ends up in the code every visitor downloads. Never use that prefix for a service role key or a Stripe secret key.
Checklist
Still stuck?
Send me the app link and what's broken. The first look is free and you get a fixed quote before I touch anything.
Related guides
- Bolt.new Stripe webhook not working after deploying to Netlify (404 or no upgrade)
- Lovable custom domain with Cloudflare: fix "too many redirects" (ERR_TOO_MANY_REDIRECTS)
- Lovable custom domain not working: stuck pending, no SSL, or www fails
- Lovable email verification not working: signup confirmation emails not arriving
- Lovable Google sign in showing redirect_uri_mismatch or an unverified app warning
- Base44 custom domain stuck on Pending verification
- Base44 payment succeeded, but the customer was not upgraded
- Lovable Stripe checkout: "Edge Function returned a non-2xx status code"
- Lovable password reset link not working or sending users to the wrong page
- Replit custom domain not working: stuck on Verifying or showing a blank page
- Is your Supabase data public? A two-minute RLS check
- “No such price” when going live: Stripe test and live mode mixed up
- Stripe payment succeeded but the user is still on the Free plan
- Subscription cancelled in Stripe but the user still has the paid plan
- Stripe webhook signature verification failed (400): causes and fix
- Login sends users to localhost or the preview URL after publishing
- Supabase update returns no error but nothing changes