Muhammad Usman

· Muhammad Usman

Why your Lovable app breaks in production (and how to fix it)

Lovable apps that work in the preview often fail with real users: auth, database security, payments, emails and deployment. The common causes and the fixes.

The short answer

  • Most Lovable apps break at the same five places: sign-in, database security rules, payments, emails and the move to a real domain.
  • These are rarely bugs in the screens you can see. They sit in configuration and server-side logic the preview never exercises.
  • Prompting the AI again usually patches one symptom and moves the problem. Reading the code and the database rules is faster.
  • You almost never need a full rewrite. An audit tells you what to keep, what to repair and what to rebuild.

The preview is not production

Lovable is very good at getting a working interface on screen. In the preview you are usually the only user, logged in as yourself, on a test database, with no real money moving. Almost everything that goes wrong after launch comes from the things that preview never tests: more than one user, users who should not see each other's data, real payments, real email inboxes and a real domain.

So when founders say the app worked yesterday and broke when the first customers arrived, the app usually did not change. It simply met conditions it was never built or tested for.

1. Sign-in works for you, but not for your users

Lovable apps typically use Supabase for authentication. The most common failures:

  • Redirect URLs still point at the preview address, so email confirmation and password reset links send users to the wrong place after you move to your own domain.
  • Google or other social sign-in is configured with test credentials or the wrong callback URL.
  • New users are created in the auth system but no matching profile row is written, so the app crashes or shows an empty dashboard after their first login.
  • Roles such as admin and customer are checked only in the interface. Hiding a button is not access control.

The fix: update the site and redirect URLs in the auth settings for every domain you use, create the profile row with a database trigger instead of front-end code, and enforce roles on the server and in the database.

2. Users can see each other's data

This is the most serious one, and it is easy to miss because everything looks fine when you test alone. Supabase protects data with row level security (RLS): rules in the database that decide which rows each user may read and change. If RLS is off on a table, or the policy is too broad, any signed-in user, and sometimes anyone at all, can read or edit every row through the public API.

  • Check that RLS is enabled on every table that holds user or customer data.
  • Check every policy: a rule like "authenticated users can select" means every user sees every row.
  • Make sure the service role key, which bypasses RLS entirely, never appears in front-end code or in the browser.
  • Test with two separate accounts and try to load the other account's records directly.

If your app stores anything personal, such as names, emails, orders or health or financial details, fix this before you invite more users.

3. Payments half-work

Stripe checkout opening is the easy part. What generated apps often miss is everything that happens after the payment:

  • The app marks an order as paid when the user lands on a success page, instead of when Stripe confirms it with a webhook. Users who close the tab never get what they paid for, and anyone who opens the success URL gets it free.
  • Webhooks are not verified with the signing secret, so a forged request can unlock paid features.
  • Subscriptions are created but cancellations, failed renewals and plan changes are never handled.
  • Test keys are still in use, or live keys are mixed with test webhooks.

The fix is a small server-side function that receives Stripe's webhook, verifies it, and is the only place that updates payment status in the database.

4. Emails never arrive

Sign-up confirmations and password resets often go out through a default email service meant for development, with low sending limits and no domain authentication. They land in spam or stop after a handful a day. Contact forms may also post to a third-party form service that is not set up for the address you expect.

The fix: send through a proper email provider from an address on your own domain, add the SPF, DKIM and DMARC records it asks for, and test a full sign-up and reset on a fresh inbox.

5. Every new prompt breaks something else

After a few weeks of prompting, the code tends to have large components doing many jobs, logic duplicated in several places, and no tests. Each change the AI makes is reasonable in isolation, but it cannot see everything that depends on the code it is editing. That is why fixing the checkout breaks the dashboard.

This is the point to stop prompting and have someone read the code. Pulling shared logic into one place, adding a few tests around sign-in and payments, and putting the project under proper version control makes it stable enough to keep building on, by a developer or by the AI again.

A pre-launch checklist

  1. Row level security on every table, tested with two accounts.
  2. No secret keys in front-end code; secrets only in server-side environment variables.
  3. Auth redirect URLs set for your real domain.
  4. Payment status updated only by a verified Stripe webhook.
  5. Emails sent from your own domain with SPF, DKIM and DMARC.
  6. Input validated on the server, not only in the form.
  7. Error monitoring switched on, so you hear about failures before users tell you.
  8. Code in a Git repository you own, with a working backup of the database.

Keep, repair or rebuild?

Most Lovable projects have a usable base: the screens, the data model and the flow are often fine. The work is usually repairing security and server-side logic rather than starting again. A rebuild only makes sense when the data model is wrong for the product, and that should be decided from an audit with the reasons written down, not from frustration.

Questions

Is Lovable good enough for a production app?

It can be the start of one. Lovable produces real React code and usually a Supabase backend, which can run in production. What it does not guarantee is correct security rules, payment handling and configuration, so those need checking before real users arrive.

Can I keep using Lovable after a developer fixes my app?

Often, yes. If the fixes keep the project structure Lovable expects and live in the same repository, you can carry on prompting. A developer can tell you which parts to leave alone.

How long does it take to make a Lovable app production-ready?

It depends on the size of the app and what is broken. An audit comes first, and the audit produces a fixed list of work, so you know the scope before any repair starts.

More articles

Tell me what's not working.

No commitment in a first conversation. Describe the problem and I'll tell you straight whether I'm the right person to solve it, and roughly what it would take.