Ryz Labs/Rescue/Lovable to production
Rescue

Lovable to Production: Hardening a Supabase-Backed App

The front end usually survives. What gets rebuilt is trust: row-level policies, Edge Function authorization, key hygiene, tests and a branch workflow engineers can share with Lovable.

Taking a Lovable app to production means keeping the React front end and the Supabase data model your team already validated, then hardening the parts real users and security reviewers will lean on: row-level policies, Edge Function authorization, key handling, tests and a deploy path that isn't a button in the builder. Harden in place and replace only what can't be fixed. For Lovable specifically, success is decided in the database: if every table's policies check who owns the row, most other problems become ordinary engineering work.

What Lovable gives you, and where production starts

Every Lovable project uses the same stack. According to the Lovable FAQ, new apps use TanStack Start, which renders pages on the server, while older apps use React and Vite and render in the browser, so check which one you have before you plan the work.

The docs say plainly that "the built-in backend is enabled for your workspace" by default, and that it "utilizes Supabase's open-source foundation." (Older posts call this Lovable Cloud; the current page is titled "Built-in backend", and only the permission toggle still reads "Enable Cloud".) You can instead connect a Supabase project you own, though Lovable notes most projects never need one. Moving between the two is a manual export and rebuild, so decide early where production lives.

Lovable's Secrets are encrypted, injected into your Edge Functions, and never reach the browser, and the product detects API keys pasted into the project chat and steers them into Secrets. A Quick scan runs on publish (database rules, dependencies, MCP exposure); a Deep scan reviews access control, injection, leaked secrets, auth and payments, but only when someone starts it. Add auto-fix for Quick-scan findings, a setting that blocks publishing on critical issues, a Security center on Business and Enterprise, and Wiz and Aikido connectors.

Code leaves Lovable through GitHub two-way sync, with a caveat that shapes your workflow: "Lovable only edits and syncs one branch at a time," the default branch unless you pick another. Disconnecting leaves the repository on GitHub. Published apps can run on your own domain: custom domains are on paid plans and SSL is issued automatically.

That is a strong prototype platform. Production asks other questions: who can read which rows, where keys live, how a release is tested and rolled back, and who gets paged. Real money needs webhooks that can't be replayed and entitlements nobody can edit from a browser console. Lovable itself is direct about the limit: its scans "do not replace a thorough security review."

The failure modes we see first

Worst first, for a React app using the publishable key, with server logic in Edge Functions.

1. Policies that check "signed in" instead of "owns this row"

The browser talks to Postgres directly, and the publishable key "it only reaches what Row Level Security allows," so RLS is the only thing between a visitor and your data. Tables created through SQL, rather than the dashboard, start without RLS enabled, and on existing projects a new public table starts with every privilege granted to anon, authenticated and service_role. The subtler case is a policy that only asks whether the caller is signed in, so any account can list every invoice. Views also bypass RLS by default.

This is the context for CVE-2025-48757, a disputed CVE describing insufficient RLS policies in sites generated by Lovable through April 2025. Lovable disputes it, holding that configuring RLS is the customer's responsibility. Either way, the lesson matches Lovable's own docs: "Misconfigured RLS rules are a common cause of data leaks."

Check: wherever you have database access, run the Supabase database linter alongside Lovable's Quick scan and look for 0013 rls_disabled_in_public (level ERROR, "Table publicly accessible") and 0008 rls_enabled_no_policy. Then the test no linter does: sign in as account A and use the publishable key to select and update account B's rows. Fix: write policies that compare (select auth.uid()) to an owner or membership column, with both USING and WITH CHECK clauses so users can't insert rows on someone else's behalf. Recreate views so they run with the caller's permissions or move them behind a function. Turn off "Automatically expose new tables" so new tables stay off the Data API until someone decides otherwise.

2. Admin by editing your own profile

Generated schemas often keep role, plan or is_admin on the same profiles row the user is allowed to update. "Users can update their own profile" is right for display names and disastrous for roles: one PATCH and a free user is an admin.

Check: list every column on any table with a self-update policy, and try changing the privileged ones from a normal session. Fix: move roles and entitlements to a separate table that only server code writes, revoke column-level update on the sensitive fields, and have the React app read permissions rather than store them.

3. Keys in the wrong place, or in the history

Code drifts once engineers and the builder both touch it: a secret key pasted into front-end config while debugging, a committed .env file, or AI-written setup notes that still use long eyJ tokens. Supabase is clear that a secret key "bypasses Row Level Security, so it must never leave your control," and that the legacy anon and service_role keys are being deprecated by the end of 2026 in favor of sb_publishable_ and sb_secret_ keys, which are short strings rather than JWTs.

Check: turn on GitHub secret scanning for the synced repo, and search the built JavaScript bundle for sb_secret_ and eyJ strings. Fix: rotate anything that was ever exposed (deleting the commit is not enough), move the value into Lovable Secrets or supabase secrets set on a project you own, read it with Deno.env.get inside the function, and plan the move to publishable and secret keys before the deprecation lands. Enable push protection on the repository so the next leak is blocked at push time.

4. Edge Functions that believe the request body

Anything needing a secret runs in an Edge Function, and the default secrets include SUPABASE_SECRET_KEYS, which bypass Row Level Security. A function that takes a user_id from its JSON body and queries with that key skips every policy from step one. This is OWASP's Broken Object Level Authorization (API1:2023).

Check: for each function, find the line where it decides whose data it is touching. If that identity comes from the request payload rather than the verified JWT, it's a finding. Fix: derive the user from the Authorization header, prefer a client created with the caller's token so RLS still applies, and keep the secret key for the narrow jobs that truly need it. Add input validation and per-user rate limits, especially on functions that call an LLM, where untrusted text invites prompt injection.

5. Payments that trust the browser

The usual shape: checkout succeeds, the React app flips a paid flag on the profile, and the subscription webhook (if it exists) neither verifies the signature nor handles retries. Downgrades, failed renewals and refunds are never written.

Check: search for where "paid" or the plan name gets written. If any write path starts in the client, or the webhook function has no signature verification, it fails. Fix: make the webhook Edge Function the only writer of entitlements, verify the signature, store processed event ids so duplicates are no-ops, and handle cancelled, past-due and downgraded states.

6. Policies and queries that get slow with data

RLS runs on every row a query touches, so an unindexed policy column turns list pages into sequential scans as data grows. Supabase says "Add an index on every column your policies filter on," and wrap auth.uid() in a select so it's evaluated once per statement instead of once per row. Generated components also tend to fetch their own data, one request per card.

Check: open the Performance and Health Advisors and run EXPLAIN ANALYZE on the busiest queries with a real user's JWT. Fix: index owner and tenant columns, rewrite policies with the select wrapper, and push list queries into a view or RPC that returns one shaped result. If background jobs connect through the Supavisor pooler in transaction mode on port 6543, remember it doesn't support prepared statements.

7. One synced branch, two kinds of authors, no gate

Because Lovable edits one branch, the builder usually commits straight to the branch production is built from, with no tests in between. When engineers push to that branch too, the two sides collide and nobody can say what shipped. Schema changes may exist only in the live database, with no migration to replay in staging.

Check: can you name the CI run behind the last twenty commits, and rebuild the schema from the repo? If not, this applies. Fix: covered in Phase 3 below: a deliberate branch layout, migrations in the repo, and CI that runs on every commit regardless of who wrote it.

Production readiness checklist

The hardening plan, step by step

Phase 0: Freeze and snapshot

Pause large prompts into the synced branch. Export the code, tag the commit, dump schema and policies to SQL, and list every Edge Function with the secrets it reads, plus who has workspace, GitHub and database access. Exit criteria: you can describe the current system from files in the repo, and you have a restorable copy of both code and data.

Phase 1: Security

Run both scans and the Security Advisor, and treat the output as a to-do list, not a verdict. Fix RLS table by table with the two-account test as the acceptance check, split privileged columns out of profiles, rotate exposed keys, and rewrite Edge Functions to take identity from the token. Write a one-page threat model. Exit criteria: linter clean, two-account test green on every table, no exposed credentials, every function reviewed by a person.

Phase 2: Data and performance

Seed staging with production-shaped volume and profile with real JWTs, because RLS cost only shows up under a real role. Index policy and foreign-key columns, apply the select wrapper, collapse per-component fetches into RPCs, and turn schema drift into migrations. Exit criteria: the busiest pages meet an agreed latency budget at target volume and schema changes go through migrations only.

Phase 3: Tests and CI/CD

Pick a branch layout that respects the one-branch sync. A common one: Lovable syncs its own branch, engineers use feature branches, and both merge into main through pull requests that must pass CI. Write characterization tests on the money paths (signup, checkout, the core workflow), automate the two-account check against staging, and decide whether production is published from Lovable or deployed from main by your pipeline. Exit criteria: no change reaches production without passing tests, and the team can name the commit that is live.

Phase 4: Operations

Add error tracking to the React app and the Edge Functions, structured logs with request and user ids, uptime checks, and alerts that reach a person. Write the runbook: rollback, key rotation, restore, session revocation. Exit criteria: a rehearsed rollback and restore, and an on-call rotation that knows where the logs are.

Phase 5: Re-platform only what's left

Some pieces outgrow a function per endpoint: long-running jobs, heavy reporting, complex integrations. Move only those to a service you operate, behind an API the front end calls. Exit criteria: each extracted piece has its own tests, deploy and owner.

PhaseGoalKey techniqueExit criteria
0. Freeze and snapshotKnow exactly what existsCode export, schema and policy dump, function and secret inventoryRestorable copy; system described from repo files
1. SecurityRows only reachable by their ownersOwnership policies, two-account test, JWT-derived identity in functions, key rotationLinter clean; no exposed keys; functions reviewed
2. Data and performanceFast under real roles and volumePolicy-column indexes, select-wrapped auth.uid(), RPCs for listsLatency budget met; schema in migrations
3. Tests and CI/CDEvery change is gatedBranch layout around one-branch sync, money-path tests, policy testsNothing ships without green CI
4. OperationsFailures are seen and reversibleError tracking, alerts, runbookRollback and restore rehearsed
5. Re-platformMove only what won't hardenExtract jobs and heavy logic behind an APIExtracted parts tested and owned

What an AI pod on your team does in the first two weeks

Week one

Week two

Our AI pod uses coding assistants for the repetitive parts: generating test scaffolds, drafting policies for each table, codemods across components, and triaging logs. Every change still goes through human review and the test suite before it merges.

Keep, harden or rebuild?

SituationRecommendation
Paying users, a sensible schema, problems mostly in policies and keysKeep and harden on the current backend
You need direct database operations, your own access controls, or one Supabase project for several appsPlan the move to a Supabase project you own, budgeting for the manual export and rebuild
Heavy jobs, complex integrations or reporting straining Edge FunctionsKeep the React app, extract a backend service for those parts
The data model fights the product (no owner or tenant concept, everything in one table)Rebuild the data layer; reuse screens where you can
Still searching for product-market fit, or a handful of internal usersDon't bring in a team yet; fix RLS and keys yourself and keep iterating

If the app needs a weekend of policy fixes and nothing else, do that weekend. A team pays off when customers, money or a security review make mistakes expensive.

Typical team shape

A Lovable rescue needs a tech lead who has shipped on Postgres and Supabase, one to three senior full-stack engineers comfortable in React and TypeScript, part-time security and DevOps help for the policy review and pipeline, and QA automation when checkout and billing are complicated. Many teams begin with a pod of 3 to 5 senior engineers (a tech lead plus engineers), and a full pod is about seven. Smaller rescues can start with a tech lead plus one or two engineers.

Ryz engineers on your team start from $7,000 per month (our published range is $7,000–$15,000 per engineer per month, mostly mid-level to senior), quoted per team. The arithmetic is simple: project cost = team size × months × monthly rate. Once you say go, engineers can typically start in under two weeks. Ryz engineers work on your team, reporting to your leads. Scope your team with us.

Related

FAQ

Can a Lovable app handle production traffic?

Often, yes. Supabase and React run plenty of real products. What fails first is usually correctness across many accounts, not raw traffic: policies that let one user see another's rows, unindexed policy columns, and Edge Functions that trust the request body. Fix those and load test with realistic roles before replacing anything.

Do we have to rewrite it?

Usually not. Most of the work sits in the database and the functions: ownership policies, roles out of editable rows, key rotation and tests. A rebuild makes sense when the data model has no concept of owners or tenants. Even then, the validated screens are a useful spec.

How long does it take?

It depends on the number of tables and Edge Functions, how much logic sits in the client, whether payments are involved, how much schema drift must become migrations, and whether a customer security review sets the bar. The first audit's findings list makes the rest far easier to estimate.

What does it cost?

Cost is team size multiplied by months multiplied by each engineer's monthly rate, which depends on seniority. Every quote is scoped per team after we see the codebase, and the first audit's findings drive team size more than anything. We don't give fixed prices before reading the repo.

Will we lose the ability to keep using Lovable?

No, if the branch layout is planned. Lovable syncs one branch at a time, so give it its own branch, let engineers use feature branches, and merge both through pull requests that run CI. Product people keep prompting UI while engineers own policies and tests.

Questions we didn't answer? Email info@ryzlabs.com.

Thanks — your message has been sent. We’ll get back to you soon.

Something went wrong while sending your message. Please try again or email info@ryzlabs.com.

Explore Ryz Labs

Software development servicesAI development companyIndustriesStaff augmentationAI pod teamsNearshore software developmentHire engineers by roleEngineer ratesGuidesBuyer guidesCase studiesHow we vet engineers

Ryz Labs

Senior engineers on your team. AI pod teams that ship.

Tell us what you're building. You get a scoped plan, a price and the names of the people who would do the work.

  • Only the top 1% of tens of thousands interviewed make it
  • On US business hours, including New York hours
  • Trusted by Fortune 500 engineering teams

Tell us who you need

A Ryz partner replies with a scoped team plan.

Start a conversation →

Prefer to talk? Book a 15-min call →