r/Supabase • • 10d ago

tips Supabase problems that only show up once real users arrive (from fixing a lot of AI-built apps)

I run a small dev shop in Mississauga, and these days a good chunk of my work is picking up apps that were built fast with tools like Lovable, Bolt or Cursor on top of Supabase. They usually work fine while the founder and a few friends are testing. Then real users show up and a different set of problems appears. These are the ones I keep running into.

1. Signup emails stop arriving. The built-in email sender is meant for testing and has a very low hourly limit. A launch post brings in a burst of signups and most of those people never get their confirmation link. Set up your own SMTP provider before launch, not after.

2. Auth redirects still point to localhost. Check the Site URL and the redirect URL list under Authentication. When these are wrong, magic links and password resets quietly send people to the wrong place. Check your OAuth provider settings against the production domain too.

3. RLS policies that get slow as tables grow. A policy like user_id = auth.uid() works, but the function gets called for every row. Writing it as user_id = (select auth.uid()) lets Postgres evaluate it once per query. Add an index on the column the policy filters on as well. Supabase's RLS performance docs cover this, and the Performance Advisor in the dashboard can flag it for you.

4. Running out of database connections. If serverless functions connect straight to Postgres, each invocation can open its own connection and you hit the limit during a busy hour. Use the pooler connection string in transaction mode for anything serverless. This mostly matters for direct Postgres clients like Prisma or Drizzle, since supabase-js goes through the API.

5. Turning RLS off to fix a permission error. "permission denied" or "new row violates row-level security policy" (both error 42501) usually means a missing policy or missing grants for the anon or authenticated role, often on a table added later by a migration. Read the error and fix the policy or grant. Disabling RLS makes the error go away and leaves the table open to anyone with your anon key, which is public by design.

6. Storage buckets that are public when they shouldn't be. Fine for avatars. Not fine for invoices, ID documents or anything a user uploaded expecting it to stay private. Use a private bucket and signed URLs.

7. Still on the free plan with paying customers. Free projects get paused after a stretch of inactivity, which is fine for a side project and bad for an app people pay for. A paid plan also gives you daily backups.

None of this is exotic. It just doesn't come up until there's real traffic. What would you add to the list?

68 Upvotes

23 comments sorted by

17

u/burggraf2 Supabase team 10d ago

It's a good idea to go through our Production Checklist before taking any project live:
https://supabase.com/docs/guides/deployment/going-into-prod
Your list is great, though, and good advice for developers ready to go live!

3

u/junal 10d ago

Good call, that checklist is worth going through before any launch. Mine was more about the stuff I keep seeing after people skip it, so linking the official one alongside is a better starting point.

3

u/Other_Attention_1909 10d ago

Point 4 is missing the part that actually breaks: transaction mode doesn't keep prepared statements, so Prisma or Drizzle will throw "prepared statement s0 already exists" on the second request unless you turn them off. Telling someone to just swap the connection string is how they end up back in the same thread next week.

2

u/junal 10d ago

You're right, that's the part that actually bites. In transaction mode prepared statements don't carry over, so with Prisma you add pgbouncer=true to the connection string, and with Drizzle on postgres.js you set prepare: false. And keep the direct connection for migrations. Swapping the string alone is half the fix, thanks for adding it.

2

u/Greenishreddish 10d ago

Phew. I'm glad I ticked off most of these on my current project. The RLS policy efficiency one was good to learn though!

2

u/junal 10d ago

Nice, sounds like you're in good shape. The RLS one is easy to miss because everything works fine until the tables get big.

2

u/jphilippek 9d ago

Good list. A few I'd add, all from apps where RLS was technically on:

  • Policies that only check the user is signed in (auth.role() = 'authenticated') instead of ownership. Everything looks fine until a second real user shows up and can read the first one's rows. Testing with two accounts catches it in minutes.
  • The plan or role living in the user's own profile row, with an update policy that lets users edit their own row. One request and they're on Pro or admin. Worth blocking updates on those columns or moving them out.
  • Views and security definer functions quietly skipping RLS. Views need security_invoker = true or they run with the owner's rights.
  • The service_role key ending up in a VITE_ or NEXT_PUBLIC_ variable after someone "fixed" an RLS error with it.

Same pattern as your list: none of it shows up while it's just you testing with one account.

1

u/junal 9d ago

Really good additions. The plan or role living in the user's own profile row is a nasty one because nothing looks broken until someone tries it. Revoking update on those columns, or moving billing fields into a table only the server writes to, closes it. And yes on security_invoker, worth knowing it needs Postgres 15 or newer, so an older project has to upgrade first. Testing with two accounts is probably the cheapest check on this whole list.

1

u/Dazzling_Path_4125 10d ago

The (select auth.uid()) trick gets way more attention than it deserves. If there's no index on user_id the planner ends up doing a seq scan anyway and the initplan saves you nothing. The Performance Advisor flag is the part worth checking first.

1

u/junal 10d ago

Fair point, and I should have said it more clearly. Without an index on user_id the wrapper doesn't buy you much since it's still scanning the table. Index first, then the select wrapper, and the Performance Advisor is the quickest way to see which one you're actually missing.

1

u/cyber_punk000 6d ago

Great list, and I'd add a few from the security side, since they're the ones that turn into data leaks rather than outages:

  1. service_role key in the frontend. AI tools sometimes reach for it to "fix" a permission error. It bypasses RLS entirely, so anyone who opens dev tools has full database access. It should only ever live server-side.
  2. Policies that cover SELECT but not INSERT/UPDATE. If an update policy has no WITH CHECK, a user can change user_id on their own row and reassign it, or write into someone else's data.
  3. Views skipping RLS**.** On Postgres 15+ create them with security_invoker = true, otherwise a view can return rows the user's policies would block.
  4. SECURITY DEFINER functions in the public schema. They're callable through the API by anyone with the anon key, and they run with the creator's permissions. Move them to a private schema or check auth.uid() inside.
  5. No CAPTCHA or rate limit on signup. Pairs with your #1. A bot can burn through your email quota and fill auth.users with junk in minutes.

Quick test that catches most of these: make two normal accounts and try to read, update and delete each other's rows using only the anon key.

1

u/junal 6d ago

These are great additions, especially the WITH CHECK one. It's easy to miss because the policy looks fine when you only test reads. The security_invoker point on views catches a lot of people too. Your two-account test with only the anon key is the best quick check I know of, I'd run it before every launch.

1

u/citypainter 9d ago

This is helpful stuff, thanks.

1

u/karlitooo 9d ago

Is the bar on the floor? what the dickens.

1

u/trae_z 8d ago

Thanks for this. Well noted!

1

u/DeepToot40 5d ago

Those are great things to look for.and do. I ran into similar doing my own work with supabase.

I am curious though. How are you getting the work to look at other projects like this? Where do you find the clients at?

1

u/CellistOk6782 5d ago

This is great 👍

0

u/No_Possibility_9086 9d ago

The RLS one is the pattern I see over and over. Someone hits a permission error, the AI suggests turning RLS off "temporarily," the error disappears, and it never goes back on.

One thing worth adding to your list: RLS being ON isn't the finish line either. A policy that says using (true) is basically no policy, and views can quietly bypass the table's rules if they're not set up right. The only test I trust is acting like a stranger: grab the anon key (it's public by design, it's in your page source anyway) and try to read your own tables with it, signed out and then signed in as a different user. If rows come back that shouldn't, the dashboard telling you "RLS enabled" means nothing.

Takes ten minutes and it catches the stuff that only shows up once real users arrive, like you said.

0

u/Ambitious_Lychee_395 8d ago

I’d add a quick end-to-end test for the email stuff: sign up with an inbox outside your team, then try a password reset from a fresh browser session.
Don’t stop at “the email arrived.” Click the link and finish the reset on the production domain. That way you can tell a delivery problem from a callback that sends people to the wrong place.