Vibe Code Guardian
← All posts

What Lovable's Managed Environment Hides: 10 Gaps Between Preview and Production

Lovable builds your app in a managed environment. That convenience hides risks you won't see in the preview. Here is what to check before real users arrive. This covers the gaps Lovable's automation doesn't close.

Aaron Allen·

Most vibe coders using Lovable hit the same surprise. The app works in the preview. The deployment button turns green. Then real users arrive and something breaks. A webhook fails silently. A database policy lets the wrong user read data. An API key sits in the client bundle.

Lovable removes the editor. You prompt, it generates, it deploys. That speed is the point. But it also means the safety checks you would run in a local codebase never happen unless you make them happen. You would grep for secrets, review Supabase policies, test error boundaries. In Lovable those steps do not exist unless you add them.

The preview environment is not production. It shares infrastructure but not traffic patterns, not real webhook payloads, not the edge cases that appear when hundreds of sessions hit the same endpoint.

What Lovable handles (and what it doesn't)

Lovable manages the build pipeline, the hosting, the Supabase project, the environment variables. It wires authentication, sets up the database, configures edge functions. For a solo founder shipping a first version, that is a genuine shortcut.

What it does not do: review the code it writes for security anti-patterns, simulate production load, verify that your RLS policies actually match your data model, or catch the secrets that end up in the client bundle because a component imported a server-only module.

1. Secrets that leak into the client

Lovable stores environment variables server-side. The problem is what the AI imports. A component meant for the server gets used in a client file. A utility function reads process.env.STRIPE_SECRET_KEY and suddenly that key ships in the browser bundle.

How to check: Open the deployed app. Open DevTools → Network → filter for JS. Search the bundle for any string that looks like a key (sk_, pk_, supabase_, Bearer). If you find one, trace the import chain in the Lovable chat history. The AI likely pulled a server utility into a client component.

Fix: Move the secret logic to a Supabase edge function or a Lovable backend route. Call it from the client via fetch. Never import server-only modules in files that render in the browser.

2. Supabase RLS policies that look right but aren't

Lovable creates policies when you ask for "user data isolation" or "org-level access." The policies it writes often use auth.uid() for everything. That works for simple per-user rows. It fails when:

  • A user belongs to multiple organizations and the policy does not check org_id

  • A service role key is used in an edge function but the policy still checks auth.uid()

  • A public read policy exists on a table that should be private (common for profiles or settings tables)

How to check: In the Supabase dashboard, go to Authentication → Policies. For each table, read the policy SQL. Ask: does this policy enforce the rule I actually need, or just the rule the AI assumed? Test with two test accounts in different orgs. Try to read each other's data via the API directly (bypass the UI).

Fix: Write or adjust policies manually. Use the security definer pattern for edge functions that need elevated access. Remove public policies on any table with user-identifiable data.

3. Edge functions that fail silently

Lovable deploys Supabase edge functions for webhooks, background jobs, AI calls. The preview shows a 200 response. Production shows nothing when the function times out, hits a memory limit, or throws an unhandled exception. Lovable does not surface edge function logs in the chat.

How to check: In the Supabase dashboard, go to Edge Functions → Logs. Filter by the last 24 hours. Look for ERROR, timeout, memory limit exceeded. Trigger each webhook manually (Stripe CLI, Resend test send, a curl to your function URL) and watch the log stream.

Fix: Add structured logging (console.log(JSON.stringify({event, userId, timestamp}))). Wrap external calls in try/catch with a fallback response. Set a generous timeout in deno.json if the function does heavy work.

4. Authentication gaps the preview hides

Lovable sets up Supabase Auth with email/password and OAuth providers. The preview auto-logs you in. Real users hit edge cases:

  • Magic link emails land in spam (no custom SMTP configured)

  • OAuth redirect URLs mismatch between local preview and production domain

  • Password reset flows return a generic error because the redirect URL is not in the allow list

  • Session persistence fails on Safari because of third-party cookie handling

How to check: Use an incognito window. Sign up with a real email. Check spam. Click the magic link. Reset password. Sign in with Google/GitHub. Do this on mobile Safari. Do it on a different network.

Fix: Configure custom SMTP in Supabase (Resend, SendGrid). Add production URLs to the redirect allow list. Test the full auth loop on at least two browsers and two devices.

5. Database migrations that drift

Lovable applies migrations when you prompt for schema changes. It does not track migration history in a way you can review. Two prompts that touch the same table can produce conflicting policies, missing indexes, or orphaned columns.

How to check: In Supabase → Database → Migrations. Read the last 10 migration files. Look for: duplicate create policy statements, alter table without if not exists, missing indexes on foreign keys, columns added without defaults on non-empty tables.

Fix: Before launch, export the schema (supabase db dump --schema public). Review it. Run supabase db diff against a clean branch. Apply missing indexes. Consolidate duplicate policies.

6. Rate limits and abuse surfaces

The preview has one user: you. Production has bots, scrapers, and users who click the same button fifty times. Lovable does not add rate limiting by default. Edge functions, auth endpoints, and any public API route are open.

How to check: Load test one endpoint with hey or wrk (50 concurrent requests for 30 seconds). Watch the edge function logs for 500s or timeouts. Check Supabase Auth rate limit logs (Dashboard → Logs → Auth).

Fix: Add rate limiting in edge functions (simple in-memory map keyed by IP or user ID). For Supabase Auth, enable "Brute force protection" in Auth settings. Consider Cloudflare or Vercel edge middleware for heavier protection.

7. Error boundaries that don't exist

React error boundaries catch render errors. They do not catch async errors, promise rejections, or edge function failures. Lovable's generated UI often has no error boundary at all. A single failed fetch crashes the whole page.

How to check: In the browser console, trigger a network failure (DevTools → Network → Offline). Click around. Does the app show a friendly message, or a white screen with a console error?

Fix: Wrap the root layout in an error boundary component. Add window.addEventListener('unhandledrejection', ...) to log promise rejections. Show a toast or fallback UI for failed mutations (React Query / TanStack Query handles this if you use it).

8. Webhook signature verification missing

Stripe, Resend, GitHub, Linear. Every webhook needs signature verification. Lovable creates the endpoint. It often skips the verification middleware because the prompt did not mention it.

How to check: Open the edge function code for each webhook. Search for stripe.webhooks.constructEvent, crypto.createHmac, or the provider's verification SDK. If it's not there, the endpoint accepts any payload.

Fix: Add the verification code. Use the provider's official library. Reject invalid signatures with 400 before any business logic runs.

9. CORS and CSP headers

Lovable sets permissive CORS for development. The production deployment may still allow any origin, or block legitimate requests from your own subdomains. Content Security Policy is often absent, leaving the app open to inline script injection if an XSS vector exists.

How to check: curl -H "Origin: https://evil.com" -v https://your-app.lovable.app/api/endpoint. Check for Access-Control-Allow-Origin: *. Load the app and check the Content-Security-Policy header in DevTools → Network → Response Headers.

Fix: Restrict CORS to your production domain and known subdomains. Add a CSP header via edge function middleware or Supabase's HTTP headers config. Start with default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; and tighten as needed.

10. Backup and point-in-time recovery

Supabase enables point-in-time recovery (PITR) on paid plans. Lovable projects on the free tier may not have it. If a migration corrupts data or a bad actor deletes rows, you have no rollback.

How to check: In Supabase → Database → Backups. Confirm PITR is enabled. Note the retention window (7 days on Pro, 30 days on Team/Enterprise). Verify the last successful backup timestamp.

Fix: Upgrade the Supabase plan if PITR is off. Schedule a manual backup before any major migration (supabase db dump -f backup.sql). Store it off-site.

A practical pre-launch sequence

You do not need to do all of this in one sitting. Order them by risk:

  1. Secrets scan (5 minutes). Highest impact, easiest to fix.

  2. Auth loop test (15 minutes). Real users hit this first.

  3. RLS policy review (20 minutes). Data leaks are existential.

  4. Edge function log audit (10 minutes). Catches silent failures.

  5. Webhook verification (10 minutes). Money flows through these.

  6. Rate limit test (15 minutes). Prevents abuse on day one.

  7. Error boundary check (10 minutes). UX insurance.

  8. CORS/CSP headers (10 minutes). Defense in depth.

  9. Migration review (20 minutes). Do this once before launch.

  10. Backup confirmation (2 minutes). Peace of mind.

Total: roughly two hours. Less than the time it took to build the app.

When to bring in a second pair of eyes

If the app handles payments, stores health data, or serves business customers, the cost of a missed gap exceeds the cost of a review. Vibe Code Guardian's launch-readiness audit covers all ten points above plus a manual code review of the generated edge functions, database schema, and client bundle. You get a written report with severity ratings and fix guidance. See packages for what's included.

If you want a faster signal, start with the free surface check. It scans the deployed app for exposed keys, public RLS gaps, missing error boundaries, and basic auth configuration. No code access needed, results in minutes.

The pattern behind the gaps

Every item on this list stems from the same root cause. Lovable optimizes for the happy path. The preview shows the feature working. The edge cases are missing secrets, failed webhooks, policy mismatches, and rate limits. Those only appear under real traffic.

You cannot prompt your way out of this. The AI does not know your threat model. You have to verify the things the preview hides. The checklist above is the verification step that turns a working prototype into a product you can put in front of customers.

Want a developer to look at your app?

Built your app with AI tools? Run the free surface check yourself in a few minutes. Nothing to buy, and we never look at your app unless you run it.