Skip to content
toujiBook a call

Guide

Your Lovable or Bolt app breaks in production: what to check first

The order we check things in when an app built with Lovable or Bolt works in preview but fails with real users.

Published

The app worked in the builder’s preview. Then real users arrived, and now sign-ups fail, payments don’t unlock anything, or pages go blank on refresh. Prompting the AI tool to “fix it” changes things, but not always the right things.

Most of these failures come from a short list of causes. This guide covers them in the order we check them. Several of the checks are also security checks, because the setup that breaks under real traffic is often the setup that leaks data.

Start with what actually broke

Before you change anything, collect evidence. Guessing leads to more prompts, and more prompts lead to more changed code.

  • Browser developer tools. Open the console and the network tab, repeat the failing action, and note any red errors and failed requests with their status codes. A 401 or 403 points to auth or database rules. A 404 on a page refresh points to deploy settings. A 500 points to server code.
  • Hosting logs. Your host keeps logs for builds and for server functions. Look at the time of the failure.
  • Supabase logs. If the app uses Supabase, which both Lovable’s built-in backend and Bolt’s database option are built on, the logs show API, auth, storage and Edge Function errors.
  • Get the code into Git. Both Lovable and Bolt can sync a project to GitHub. You need a history of changes before you start fixing anything.

1. Environment variables and secrets

A value that exists in preview but not in production makes an app work in one place and fail in another. A secret in the wrong place does worse: it works everywhere, including for an attacker.

  • Check every variable is set for production. Hosts scope variables to environments. On Vercel, a variable added only for Preview isn’t applied to Production, and changes only apply to new deployments, so redeploy after adding one.
  • Know which values are built into the browser code. If the project has a vite.config file, any variable starting with VITE_ is bundled into the client code at build time. Changing it means rebuilding, and anyone can read it. Lovable’s docs draw the same line between VITE_ values and backend secrets.
  • Keep secret keys off the browser. The Supabase publishable key (or the older anon key) and project URL are meant to be public. The Supabase secret key (or the older service_role key) bypasses all database rules and must stay on a server. With Stripe, only publishable keys are safe outside your back end. Keys for AI APIs, email and SMS providers are secrets too, and belong in your backend’s secret store, such as Supabase Edge Function secrets.

How to check. Build the app and search the output folder (usually dist/) for sk_live, sk_test, sb_secret_ and the names of your other providers. Then check the repository and its history. A committed .env file is normal in a Lovable project, because Lovable needs it for VITE_ values, so what matters is what’s inside it. GitHub’s secret scanning checks for supported key formats. If a secret was ever exposed, rotate it first and clean up afterwards: GitHub’s guide to removing sensitive data explains why, and Supabase has a guide to rotating leaked keys.

2. Auth and session checks on server routes

Hiding a button from users who aren’t allowed to use it is not access control. Anyone can call your API directly. Broken access control is first on the OWASP Top 10.

Every server route, API endpoint and Edge Function needs to answer two questions:

  1. Who is calling? Verify the user’s token on the server. In Supabase server code, the docs say to never trust getSession(), because it reads the cookie without checking it. Use getClaims(), which verifies the token. Supabase Edge Functions check the token by default through the verify_jwt setting. Leave it on for anything a signed-in user calls.
  2. Is this caller allowed to do this to this record? Being signed in is not enough. The OWASP Authorization Cheat Sheet recommends denying by default and checking permissions on every request.

Don’t decide who is an admin from user metadata. In Supabase, users can edit their own user_metadata, so a role stored there lets anyone make themselves an admin.

How to check. Create two test accounts. Sign in as the first, copy a request from the network tab, and change the record ID to one that belongs to the second account. Then send it again with no token at all. Both should fail.

3. Supabase Row Level Security

When front-end code calls Supabase directly, for example supabase.from('orders').select(), it uses the publishable key. That key is in every visitor’s browser, so the database rules are the only thing standing between a visitor and your data. In Supabase’s words, a table in an exposed schema without Row Level Security (RLS) is readable and writable by any role with a grant on it.

Tables created in the Supabase dashboard get RLS turned on, but tables created in the SQL editor or another tool need it turned on explicitly. That includes tables an AI tool creates through migrations, so check each one. A policy written as using (true) switches RLS on in name only: the Security Advisor flags it as a policy that allows unrestricted access.

RLS also breaks apps in the other direction. With RLS on and no policy for an action, reads come back empty and writes fail, so the app shows blank lists or won’t save.

How to check. Open the Security Advisor in the Supabase dashboard, or run supabase db advisors with the Supabase CLI. Lovable and Bolt also run their own checks (Lovable, Bolt). Lovable’s own docs say its checks can’t guarantee your app is secure, so treat them as a first pass. For a fuller list, see our Supabase security checklist.

4. Payments and webhooks

Payment bugs cost money in both directions: customers who paid and got nothing, or users who got paid features without paying.

  • Don’t unlock anything from the success page. Stripe says you can’t rely on the checkout landing page for fulfilment, because the customer may never load it. A webhook from Stripe to your server should mark the order paid.
  • Verify the webhook signature. Without it, anyone can send fake events to your endpoint. Verification needs the raw request body; a framework that parses the body first makes it fail. If the webhook runs on a Supabase Edge Function, verify_jwt has to be off because Stripe doesn’t send a Supabase token, which makes the signature check inside the function the only check.
  • Handle repeats and out-of-order events. Stripe may send the same event more than once, and it doesn’t guarantee the order. Record the event IDs you’ve processed, and make fulfilment safe to run twice.
  • Match sandbox and live settings. Sandbox and live mode use different API keys, and each webhook endpoint has its own signing secret. The secret from a sandbox endpoint or from the Stripe CLI won’t verify live events.
  • Let the server decide the price. The browser should send what the customer wants to buy, never the amount to charge.

How to check. In the Stripe dashboard, open your webhook endpoint and look at its event deliveries for failures. Locally, the Stripe CLI can forward events to your machine and trigger test events.

5. Error monitoring

If users are your error reporting, you hear about problems late and without details. Add an error tracker to both the browser code and the server code. Sentry is one common choice. Upload source maps so stack traces point at your real code instead of minified bundles.

Keep personal data and secrets out of error reports and logs. The OWASP Logging Cheat Sheet lists what to leave out, such as passwords and session tokens, and Sentry documents how to scrub sensitive data.

6. Deploy and platform configuration

A handful of settings work in preview and fail on a real domain:

  • Refreshing a page returns 404. A single-page app, such as a project on Lovable’s older React and Vite template, needs the host to send every route to index.html when you deploy it yourself. Vercel documents the rewrite for Vite apps, and Netlify has the same rule.
  • Login links go to the wrong place. Supabase Auth uses the Site URL as the default redirect, and any other redirect URL has to be on its allow list. If the Site URL is still http://localhost:3000 or a preview address, confirmation and reset emails send users there. Set it to your production domain, use exact redirect URLs in production, and keep wildcards for local and preview addresses.
  • Confirmation and reset emails stop arriving. Supabase’s built-in email sender is limited to 2 emails per hour. That’s fine for testing and fails on launch day. Set up custom SMTP.
  • The backend goes to sleep. Supabase may pause Free Plan projects after a week of low activity.

7. Tests for the flows that matter

Fixes in an AI-built app tend to come undone, because the next prompt can rewrite the file that held the fix. Automated tests catch that.

Start with the flows that make or lose money: sign-up, sign-in, password reset, checkout, and the one action your app exists for.

  • End-to-end tests. Playwright drives a real browser through each flow and can reuse a signed-in session across tests.
  • Database rule tests. Supabase supports pgTAP tests run with supabase test db, which can check that one user can’t read another user’s rows.
  • Payment tests. Stripe provides test card numbers for successful, declined and authenticated payments in a sandbox.

Run the tests on every push, so a broken flow fails the build instead of reaching users.

When to bring in help

If you’ve worked through this list and the app still breaks, or the list turned up more than you want to fix yourself, we can help. We start by reading the code and the database rules, then tell you what to fix first. If you’re not sure the app is worth fixing at all, read Fix or rebuild? first.

See Vibe-coded app rescue and Security scanning and hardening, or tell us what’s broken.

Where we can help

All services

Tell us what's going on.

Describe the app and the problem in a few lines. We'll set up a call and send a written quote.