# 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 2026-11-25.

Page: https://touji.dev/guides/lovable-bolt-app-breaks-in-production

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](https://docs.lovable.dev/features/cloud) and Bolt's [database option](https://support.bolt.new/bolt-cloud/database/advanced) are built on, the [logs](https://supabase.com/docs/guides/observability/logs) show API, auth, storage and Edge Function errors.
- **Get the code into Git.** Both [Lovable](https://docs.lovable.dev/integrations/github) and [Bolt](https://support.bolt.new/integrations/git) 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](https://vercel.com/docs/environment-variables), 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](https://vite.dev/guide/env-and-mode). Changing it means rebuilding, and anyone can read it. Lovable's docs draw the same line between [`VITE_` values and backend secrets](https://docs.lovable.dev/features/secrets).
- **Keep secret keys off the browser.** The Supabase publishable key (or the older `anon` key) and project URL are [meant to be public](https://supabase.com/docs/guides/getting-started/api-keys). 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](https://docs.stripe.com/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](https://supabase.com/docs/guides/functions/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](https://docs.lovable.dev/features/secrets), so what matters is what's inside it. GitHub's [secret scanning](https://docs.github.com/en/code-security/concepts/secret-security/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](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository) explains why, and Supabase has a guide to [rotating leaked keys](https://supabase.com/docs/guides/security/rotate-leaked-api-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](https://top10.owasp.org/2025/A01_2025-Broken_Access_Control/).

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()`](https://supabase.com/docs/guides/auth/server-side/creating-a-client), 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](https://supabase.com/docs/guides/functions/auth). 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](https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html) 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`](https://supabase.com/docs/guides/auth/managing-user-data), 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](https://supabase.com/docs/guides/database/postgres/row-level-security).

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](https://supabase.com/docs/guides/api/securing-your-api). 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](https://supabase.com/docs/guides/observability/advisors).

RLS also breaks apps in the other direction. With RLS on and [no policy for an action](https://supabase.com/docs/guides/database/postgres/row-level-security), 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](https://supabase.com/docs/reference/cli/supabase-db-advisors). Lovable and Bolt also run their own checks ([Lovable](https://docs.lovable.dev/features/security), [Bolt](https://support.bolt.new/building/security)). 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](https://touji.dev/guides/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](https://docs.stripe.com/checkout/fulfillment) 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](https://docs.stripe.com/webhooks) 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](https://supabase.com/docs/guides/functions/auth) the only check.
- **Handle repeats and out-of-order events.** Stripe may send the [same event more than once](https://docs.stripe.com/webhooks), 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](https://docs.stripe.com/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](https://docs.stripe.com/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](https://docs.sentry.io/platforms/javascript/) is one common choice. Upload [source maps](https://docs.sentry.io/platforms/javascript/sourcemaps/) 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](https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html) lists what to leave out, such as passwords and session tokens, and Sentry documents how to [scrub sensitive data](https://docs.sentry.io/security-legal-pii/scrubbing/).

## 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](https://docs.lovable.dev/features/upgrade-to-tanstack-start), needs the host to send every route to `index.html` when you deploy it yourself. Vercel documents the [rewrite for Vite apps](https://vercel.com/docs/frameworks/frontend/vite), and Netlify has [the same rule](https://docs.netlify.com/manage/routing/redirects/rewrites-proxies/#history-pushstate-and-single-page-apps).
- **Login links go to the wrong place.** Supabase Auth uses the Site URL as the [default redirect](https://supabase.com/docs/guides/auth/redirect-urls), 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](https://supabase.com/docs/guides/auth/rate-limits). That's fine for testing and fails on launch day. Set up [custom SMTP](https://supabase.com/docs/guides/auth/auth-smtp).
- **The backend goes to sleep.** Supabase [may pause Free Plan projects](https://supabase.com/docs/guides/deployment/going-into-prod) 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](https://playwright.dev/docs/intro) drives a real browser through each flow and can [reuse a signed-in session](https://playwright.dev/docs/auth) across tests.
- **Database rule tests.** Supabase supports [pgTAP tests](https://supabase.com/docs/guides/database/testing) 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](https://docs.stripe.com/testing) 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?](https://touji.dev/guides/fix-or-rebuild-vibe-coded-app) first.

See [Vibe-coded app rescue](https://touji.dev/services/vibe-coded-app-rescue) and [Security scanning and hardening](https://touji.dev/services/security-scanning), or [tell us what's broken](https://touji.dev/contact).

## Contact

To start, book a call or send a short note about your business and the problem at https://touji.dev/contact. The intro call is free. After the call we send a written, fixed-scope quote, so the full cost is known before any work starts. We do not publish prices. On-site across Los Angeles and Orange County. Remote anywhere.
