Netcraft

// From Lovable, Bolt or Replit to production

How do you secure the Supabase database behind a Lovable app?

Enable row-level security (RLS) on every table in the public schema, write policies that compare (select auth.uid()) with the row owner for reads and writes, keep the secret key out of the browser, make private storage buckets private, and check who calls each edge function. Lovable's pre-publish scan flags missing RLS, but it cannot prove your policies are correct.

Want it done for you? Vibe-code to Production: from €1,500, fixed quote in 24h →

Gabriel Cazaciuc

By , Founder & lead developer, Netcraft Digital

Last updated

Key facts

RLS on, no policies
No data reachable with the publishable key
Source: Supabase docs, Nov 2026
Secret / service_role key
Bypasses RLS; backend only
Source: Supabase docs, Nov 2026
Legacy anon and service_role keys
Being deprecated in early 2027
Source: Supabase docs, Nov 2026
Lovable security checks
Do not block publishing by default and “can't guarantee that your app is secure”
Source: Lovable docs, Nov 2026
Security fixes with us
From €1,500, 3–4 days, written report
Source: Our fixed-price offer, Nov 2026

Why is a Lovable + Supabase app open by default?

Because the browser talks to the database directly. A Lovable app ships the Supabase URL and the publishable (or legacy anon) key in its JavaScript, and that key can query any table through Supabase's API. The only thing that limits what it returns is row-level security.

Lovable's built-in backend runs on Supabase, and Lovable's pre-publish checks flag tables without RLS. The problems that remain are subtler: a table added in a hurry, a policy loosened to make an error go away, a column the user can edit that decides what they are allowed to do.

How can I test my own app in five minutes?

Do what an attacker would do: take the key from your site and ask the API for a whole table, without logging in. Open your published app, find the Supabase URL and key in the browser's network tab, then run:

curl "https://YOUR-PROJECT.supabase.co/rest/v1/profiles?select=*" \
  -H "apikey: YOUR_PUBLISHABLE_KEY"

Repeat for every table. Any table that returns other people's rows is a leak. Then log in as one test user, copy the access token, add it as an Authorization: Bearer header, and check that you only get that user's rows.

What does a correct RLS policy look like?

One policy per action, each checking the owner, with a WITH CHECK on inserts and updates so users cannot write rows in someone else's name. Wrap auth.uid() in a select, as Supabase recommends, so it runs once per query instead of once per row.

alter table public.projects enable row level security;

create policy "read own projects" on public.projects
  for select to authenticated
  using ((select auth.uid()) = user_id);

create policy "create own projects" on public.projects
  for insert to authenticated
  with check ((select auth.uid()) = user_id);

create policy "update own projects" on public.projects
  for update to authenticated
  using ((select auth.uid()) = user_id)
  with check ((select auth.uid()) = user_id);

create policy "delete own projects" on public.projects
  for delete to authenticated
  using ((select auth.uid()) = user_id);

Which mistakes does the Lovable scan not catch?

The scan checks whether RLS is on and whether a rule lets everyone in. It does not know what your app is supposed to allow. These are the patterns we look for by hand:

PatternWhy it leaksFix
using (true) for the authenticated roleEvery logged-in user reads every row; sign-up is free, so this is the same as publicCompare with the owner or an organization membership
Role or plan column on the profiles table, with an “update own profile” policyUsers set role = 'admin' or plan = 'pro' on their own rowMove role and plan to a table users cannot write, or limit updatable columns
Policies that read user_metadataUsers can change their own user_metadataUse app_metadata or a table for authorization data
Views over protected tablesViews bypass RLS by defaultCreate them with security_invoker = true (Postgres 15+)
SECURITY DEFINER functions in the public schemaCallable through /rest/v1/rpc and they skip RLSMove them to a private schema or check auth.uid() inside
Edge functions using the secret keyThe secret key bypasses RLS, so the function must check the caller itselfVerify the user's token and ownership in the function
Public storage bucket for invoices, IDs or uploadsAnyone with the URL can download the filePrivate bucket with storage policies and signed URLs

The second row is easy to miss in apps with paid plans: the plan is stored on the user's own profile, and the profile policy lets the user update their row. With the browser console, they can upgrade themselves for free.

Which Supabase key goes where?

The publishable key goes in the browser; the secret key only on a server or in an edge function. If a secret key was ever committed to the repo or pasted into the frontend, rotate it.

KeyFormatWhere it belongsBypasses RLS
Publishablesb_publishable_…Browser, mobile appNo
Secretsb_secret_…Server, edge functions, jobsYes
anon (legacy)Long-lived JWTBrowser (replace with publishable)No
service_role (legacy)Long-lived JWTServer only (replace with secret)Yes

Supabase is deprecating the legacy anon and service_role keys in early 2027. Switching to the new keys is a good moment to search the codebase for any place the elevated key is used.

What is the full checklist before launch?

Lovable + Supabase security checklist

  • RLS enabled on every table in the public schema (check More → Database → Manage → Policies in Lovable, or the Supabase dashboard)
  • Every table has explicit select, insert, update and delete policies, or the action is intentionally denied
  • Inserts and updates have WITH CHECK on the owner column
  • No policy uses true for authenticated users on private data
  • Role, plan, credits and payment status cannot be written by the user
  • No authorization decisions read user_metadata
  • Views use security_invoker = true or are not exposed
  • No SECURITY DEFINER functions in exposed schemas without their own checks
  • Secret key only in server code and edge function secrets; none in the repo
  • Private buckets are private; files served with signed URLs
  • Each edge function verifies the caller and what they are allowed to touch
  • The curl test above returns nothing for anonymous users on private tables

Run the list again after every large prompt. An AI fix for an unrelated error can drop a policy or widen it, and nothing in the preview will look different. For the risks outside the database (exposed API keys, payments, AI cost abuse), see vibe coding security risks.

How do you do this without Supabase?

Our own products run on Next.js, Payload and Postgres without Supabase. The browser never talks to the database; every read and write goes through server code that checks the session first. That is the same rule RLS enforces, placed in a different layer. If your app is moving to your own hosting, either model works, as long as it is applied to every table.

Security is the first item on the production checklist for AI-built apps. If payments are next, read how to add Stripe to a Lovable app, or ask a Lovable developer to review the code.

// FAQ

Frequently asked questions

Another question? Write to us; you get an answer from the developer within one working day.

Is Lovable secure?

The generated code can be secure, and Lovable runs automatic checks before publishing. Those checks do not block publishing by default and Lovable itself says they cannot replace a security review, so check your policies before real users arrive.

Does Lovable enable RLS automatically?

Lovable's pre-publish scan flags tables without RLS. It cannot know whether a policy matches what your app should allow, which is where most leaks come from.

Is it safe that my Supabase key is visible in the browser?

Yes for the publishable or anon key, if every table has correct RLS policies. Never for the secret or service_role key, which bypasses RLS.

How do I see all RLS policies in a Lovable project?

In Lovable, go to More → Database → Manage → Policies. If you use your own Supabase project, the Supabase dashboard lists them per table.

What happens if I enable RLS without policies?

Nothing is readable or writable through the API with the publishable key until you add policies. Your app will break, but no data leaks.

// From Lovable, Bolt or Replit to production

Keep reading

// From Lovable, Bolt or Replit to production

What are the security risks of vibe coding, and how do you check for them?

The main risks in vibe-coded apps are database tables readable with the public key, secret API keys in the browser, permissions checked only in the interface, payments granted by the client, AI endpoints anyone can call, and unreviewed packages. AI tools build what works when you click through it, not what an attacker would try. Each has a quick test.

Read the guide

// From Lovable, Bolt or Replit to production

How do you add Stripe payments to a Lovable app?

Lovable offers two paths: built-in payments, where Lovable sets up Paddle or Stripe for you (paid plan required), or your own Stripe account connected with a restricted key. The own-account setup checks subscription status with Stripe at sign-in and has webhooks off by default. For production, add a verified webhook that writes each user's access to your database.

Read the guide

// From Lovable, Bolt or Replit to production

How do you move a Lovable app to your own hosting and GitHub?

Connect the project to GitHub (two-way sync, all Lovable plans), check package.json for React + Vite or TanStack Start, and deploy the repo to Vercel or Netlify with the same environment variables. Then move the backend to your own Supabase project: schema from migrations, data and users from a database export, files from storage, secrets re-added by hand.

Read the guide

// Start here

How do you take a Lovable, Bolt or Replit app to production?

To take an AI-built app to production you need five things the builder rarely finishes: database access rules on every table, payments confirmed on the server, hosting and a database in your own name, pages Google can read, and code you can change without breaking it. With a developer this usually takes 3–7 days and costs €1,500–3,000.

Read the guide

Vibe-code to Production, at a fixed price

Security, payments, hosting, domain and SEO for apps made with AI builders. From €1,500, 3–7 days. Written scope and price within 24 hours.