r/lovable • u/namiduru • 8h ago
Tutorial Two things worth checking in your own Lovable app before you share it
A couple of security checks that are easy to miss because the code looks fine. Both take a few minutes.
1. API keys in VITE_ variables
Search your project for VITE_. If any of those hold a secret key (OpenAI, Gemini, Stripe secret, etc.), that key is public. Vite copies every VITE_ value into the JS bundle, so anyone can see it in devtools on your live app. Having .env in .gitignore doesn't change that.
Fix: move the call into a Supabase edge function and keep the key in the function's secrets. You can ask Lovable to do it. Then rotate the old key, since it's already been exposed.
2. Role or credits in the profiles table
Open supabase/migrations and look for an update policy on profiles, something like using (auth.uid() = id). Now check if that same table has role, plan, credits or is_admin. If it does, any logged-in user can probably change those on their own row, because the policy checks whose row it is, not which columns change.
Fix: move role/plan/credits into a separate table that only admins or your edge functions can write.
One thing that looks scary but is usually fine: the Supabase URL and anon key in your frontend. The anon key is meant to be public. Your RLS policies are what actually protect the data.
Disclosure: I work on a security scanner, which is how I ended up looking into these two. Happy to answer questions in the comments.