How do I enable RLS in Supabase before publishing an app built with Lovable or Bolt?
Before publishing a Lovable or Bolt app, enable RLS on every Supabase table, create policies so each user only accesses their own rows, and keep the service_role key out of the frontend. RLS is configured in Supabase, not on your hosting.
To enable RLS in Supabase before publishing a Lovable or Bolt app, run alter table table_name enable row level security; on every table in the public schema and create policies that only let each user read and modify their own rows, for example with auth.uid() = user_id. RLS is configured in Supabase, not on your hosting.
In the command, replace table_name with the name of each table. Then test the app while signed in and while signed out, confirm that the service_role key is not in the frontend or in the repository, and review your environment variables.
What RLS is and why it matters before you publish
RLS (Row Level Security) is a Postgres feature that Supabase uses as its main security layer. With RLS enabled, every query to a table goes through rules called policies. These rules decide which rows the requester can view, create, edit or delete.
The risk comes from how apps generated with Lovable or Bolt work. The browser talks directly to Supabase using the project URL and the public (anon) key. That key ships in the frontend code, so anyone can see it with the browser's developer tools. This is normal and by design, but it is only safe if RLS protects your tables. A table in the public schema without RLS can end up readable and editable by anyone who has the anon key. They could list other users' records, modify them or delete them.
The service_role key is a different case: it is secret and bypasses RLS entirely. If it leaks, your policies no longer protect anything.
Recipe: enable RLS in Supabase for a Lovable or Bolt app
You do every step from the SQL editor of your Supabase project. Before you touch real data, test on a copy or in a development project.
1. Check which tables are in the public schema
This query lists the tables in the public schema and shows whether RLS is enabled on each one:
select tablename, rowsecurity from pg_tables where schemaname = 'public';
Any row with rowsecurity = false is an exposed table. Write them all down, including the ones the AI created along the way, such as profile, log or settings tables.
2. Enable RLS on every table
Run this command on each table, replacing table_name with the table name:
alter table table_name enable row level security;
With RLS enabled and no policies, the anon key can no longer read or write anything in that table. It's normal for the app to “stop working” at this point. The next step defines what is allowed.
3. Create minimal policies for users' own rows
Suppose you have a table called notes (notes) with a user_id column that stores the authenticated user's id. These four policies let each person manage only their own rows. The table and policy names are just examples, so use your own:
create policy "read own" on notes for select to authenticated using (auth.uid() = user_id);create policy "create own" on notes for insert to authenticated with check (auth.uid() = user_id);create policy "update own" on notes for update to authenticated using (auth.uid() = user_id) with check (auth.uid() = user_id);create policy "delete own" on notes for delete to authenticated using (auth.uid() = user_id);
using filters which existing rows can be accessed. with check validates new or modified data, which stops someone from inserting a row in another user's name. If a table should be public and read-only, such as a catalog, create only a select policy and don't allow writes from the frontend.
4. Test with a user and without a session
- Signed in: create two test accounts. Create records with account A and confirm that account B can't see or edit them.
- Signed out: sign out and open the screens that load data. No private information should appear.
- Directly against the API: if you know how, send a request to a protected table using only the anon key. It should return an empty list or an error.
5. Don't use the service_role key in the frontend or push it to the repo
Search your project for any trace of service_role. If the AI added it to “fix” a permissions error, remove it and fix the policy instead. If it has already reached GitHub, even in an old commit, regenerate the key in Supabase. Deleting the file isn't enough, because the key stays in the history.
6. Review your environment variables before publishing
In Vite projects, variables prefixed with VITE_ end up inside the code the browser downloads. Only public values belong there, such as the project URL and the anon key. Secret keys must stay on the server only, never in an exposed variable, and the .env file must be listed in .gitignore. In recent Supabase projects, the keys may be called publishable and secret, but the rule is the same: the public key goes in the frontend, and the secret one never does.
For a broader security and stability review, see how to keep an AI-built app secure and online.
What changes when you publish with Dongee Live
Dongee Live, Dongee's service for putting AI-built apps online without managing servers, publishes apps built with Lovable, Bolt, v0, ChatGPT, Claude Code, Codex, Cursor or VS Code. It publishes apps, not AI models. With Lovable and Bolt, you connect the GitHub repository: the build runs on GitHub, and every push publishes a new version. It also supports TanStack Start, Lovable's current stack, on Node 20, 22 or 24.
Live works with external services such as Supabase for the database or sign-in. You set your project's URL and public key as the app's environment variables in your client area, and those variables are also available on Live Free.
The key point: RLS is configured in Supabase, not in Dongee. Your hosting serves the app, but it doesn't decide who can read your tables. If you publish without RLS, your data is just as exposed on any server.
If you don't use Supabase, each app on Live comes with its own MySQL database, one per app, available in DATABASE_URL. That database lives on the server, and your backend queries it without exposing credentials to the browser.
An honest comparison
| Option | When it makes sense | Limits |
|---|---|---|
| Supabase with RLS + app on Live | Your app already uses Supabase Auth or Postgres, like most Lovable projects | You maintain the RLS policies in Supabase; Live does not review them |
| MySQL included with Live | New apps that can use MySQL with their own backend | One database per app; you have to adapt the code if it came from Supabase |
When Dongee Live is NOT a good fit: if you need Postgres or MongoDB on the same server as the app, because Live doesn't support them (Supabase still works as an external service). It also doesn't make sense if you're looking for a service that manages database security for you. That is still your responsibility in Supabase.
Plans: Live Free at 0 USD (1 app, commercial use subject to reasonable use), Live Pro at 15 USD/month (3 apps) and Live Team at 29 USD/month (10 apps). All of them include 24/7 human support in your language (the platform translates on the fly), even before you sign up. To compare options, read the best hosting for Lovable, Bolt or Cursor apps and where to publish an app built with ChatGPT or Lovable.
Pre-launch checklist
- Every table in the
publicschema hasrowsecurity = true. - Every table has explicit policies for select, insert, update and delete, or only the ones it needs.
- Insert and update policies use
with check. - You tested with two different users and while signed out.
- The
service_rolekey does not appear in the frontend, inVITE_variables or in your GitHub history. - The
.envfile is in.gitignore. - The published app's environment variables contain only the Supabase URL and public key.
Frequently asked questions
Do Lovable or Bolt enable RLS automatically?
Don't assume they do. Sometimes the generated code enables it and sometimes it doesn't, especially on tables created late in the project. Check with the pg_tables query before you publish.
Is it dangerous for the anon key to be visible in the browser?
Not if RLS is configured correctly. The anon key is meant to be public. The danger is using it against tables without RLS or with policies that are too permissive.
Can I configure RLS from Dongee?
No. RLS is a Postgres feature inside your Supabase project. In Dongee Live, you only set the environment variables the app uses to connect to Supabase.
What should I do if the app stops showing data after I enable RLS?
That's expected: a policy is missing. Create the minimal policy for that operation and confirm that the user_id column is filled with the authenticated user's id on insert.
Are environment variables available on Live Free?
Yes. Live Free also lets you set environment variables, so you can connect Supabase without paying for a plan.
Can I use Live's MySQL instead of Supabase?
Yes. Each app comes with a MySQL database in DATABASE_URL. You will need to adapt the code, because Lovable apps usually depend on the Supabase client and its sign-in system.
In summary
Enabling RLS is the security step you can't skip before publishing an app that uses Supabase. Review each table, create the policies, test them and protect your keys. Then publish wherever you prefer. If you choose Dongee Live, you only need to set the Supabase URL and public key as environment variables.
Comenta lo que quieras
Unete a la charla
Solo ingresa tu email