Error fixes
One error per page: what the message means, why it happens in apps built with AI, the code that fixes it and how to check the fix worked.
Fix “new row violates row-level security policy” in Supabase
new row violates row-level security policy for table "profiles"Why Supabase rejects an insert, upsert or file upload with this error, the three usual causes, and the policy that fixes it without turning RLS off.
Fix “infinite recursion detected in policy for relation” in Supabase
infinite recursion detected in policy for relation "team_members" (42P17)Appears after adding teams, workspaces or roles. Why a policy that reads its own table loops, and how a security definer function breaks the loop.
Supabase confirmation email opens localhost:3000
localhost refused to connect (after clicking the confirmation or password reset link)Your app is live, but sign-up and password reset emails still point to localhost. One setting causes it, plus the code change that keeps preview deployments working.
Fix “Error 400: redirect_uri_mismatch” with Google sign-in and Supabase
Error 400: redirect_uri_mismatchGoogle blocks sign-in because the callback address isn’t on its list. With Supabase the callback is Supabase’s address, not your app’s. Where each URL goes.
Fix CORS errors when calling a Supabase Edge Function from the browser
Access to fetch has been blocked by CORS policy: Response to preflight request doesn't pass access control checkThe function works with curl but fails in the browser. How to answer the preflight request, and why a crashed function also looks like a CORS error.
Fix “No signatures found matching the expected signature for payload” in Stripe webhooks
Webhook signature verification failed. No signatures found matching the expected signature for payloadWrong secret or a modified body. How to verify Stripe webhooks in Next.js and in a Supabase Edge Function, and why removing the check is the worst fix.
Fix 404 on page refresh after moving a Lovable or Bolt app to Vercel or Netlify
404: NOT_FOUND (on refresh or when opening a link to an inner page)The home page works, but reloading any other page gives 404. Why single-page apps do this and the one-file fix for Vercel, Netlify and Nginx.
import.meta.env variable is undefined after deploying to Vercel or Netlify
import.meta.env.VITE_SUPABASE_URL is undefinedWorks locally, empty in production. Three reasons a Vite variable goes missing, and why adding the VITE_ prefix to a secret is the wrong fix.
Your OpenAI API key is in the frontend: what to do right now
How to tell if your key is visible to visitors, the order of steps that limits the damage, and how to move AI calls to a server function with a usage limit.
Fix “remaining connection slots are reserved” on Supabase from serverless functions
remaining connection slots are reserved for non-replication superuser connectionsThe app works with a few users and fails under load. Serverless functions open a new database connection on every call. Switch to the transaction pooler and turn off prepared statements.
Supabase view returns every row even though RLS is on
The table is protected, the view on top of it is not. Why Postgres views skip row-level security by default and the one-line fix.