<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: UnbreakKit</title>
    <description>The latest articles on DEV Community by UnbreakKit (@unbreakkit).</description>
    <link>https://dev.to/unbreakkit</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4192993%2F890887df-7e32-42c3-952f-e43b451913cc.png</url>
      <title>DEV Community: UnbreakKit</title>
      <link>https://dev.to/unbreakkit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/unbreakkit"/>
    <language>en</language>
    <item>
      <title>Why Your v0 or Bolt App Fails to Deploy on Vercel (and How to Fix It)</title>
      <dc:creator>UnbreakKit</dc:creator>
      <pubDate>Sat, 31 Oct 2026 16:16:46 +0000</pubDate>
      <link>https://dev.to/unbreakkit/why-your-v0-or-bolt-app-fails-to-deploy-on-vercel-and-how-to-fix-it-1oe2</link>
      <guid>https://dev.to/unbreakkit/why-your-v0-or-bolt-app-fails-to-deploy-on-vercel-and-how-to-fix-it-1oe2</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://unbreakkit.netlify.app/guides/v0-bolt-vercel-deploy-failed.html" rel="noopener noreferrer"&gt;unbreakkit.netlify.app&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The error
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: Command "npm run build" exited with 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The real cause is earlier in the build log. Scroll up to the first red line.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common causes and fixes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. TypeScript errors (the dev server tolerates them, but &lt;code&gt;next build&lt;/code&gt; doesn't)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Type error: Property 'x' does not exist on type 'y'.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;npm run build&lt;/code&gt; locally and fix each error. As a temporary measure only, you can skip the type check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// next.config.js&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;typescript&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;ignoreBuildErrors&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since Next.js 16, &lt;code&gt;next build&lt;/code&gt; no longer runs ESLint, and the &lt;code&gt;eslint&lt;/code&gt; option in &lt;code&gt;next.config.js&lt;/code&gt; was removed. If your build still fails on lint errors, your &lt;code&gt;build&lt;/code&gt; script runs a linter itself, so fix those errors or run lint as a separate step.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Missing environment variables
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;supabaseUrl is required.&lt;/code&gt; or &lt;code&gt;undefined&lt;/code&gt; API keys. Add them in Vercel → Project → Settings → Environment Variables, then &lt;strong&gt;redeploy&lt;/strong&gt;. Variables that are read in the browser need the &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; prefix.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Module not found (case sensitivity)
&lt;/h3&gt;

&lt;p&gt;Vercel builds on Linux, so &lt;code&gt;./components/Header&lt;/code&gt; ≠ &lt;code&gt;./components/header&lt;/code&gt;. Fix the imports or rename the files. (In git, use &lt;code&gt;git mv&lt;/code&gt; for case-only renames.)&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Dependency conflicts
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;npm ERR! ERESOLVE unable to resolve dependency tree&lt;/code&gt;. Align versions in &lt;code&gt;package.json&lt;/code&gt;. As a fallback, set the Install Command to &lt;code&gt;npm install --legacy-peer-deps&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Errors while prerendering a page
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;Error occurred prerendering page "/dashboard"&lt;/code&gt;. The page fetches data or uses &lt;code&gt;window&lt;/code&gt; at build time. Move browser code into &lt;code&gt;useEffect&lt;/code&gt;, or make the route dynamic:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dynamic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;force-dynamic&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Wrong framework or output settings (common with Bolt/Vite apps)
&lt;/h3&gt;

&lt;p&gt;For Vite, set Framework Preset to &lt;strong&gt;Vite&lt;/strong&gt;, Build Command to &lt;code&gt;npm run build&lt;/code&gt;, and Output Directory to &lt;code&gt;dist&lt;/code&gt;. For client-side routing, add &lt;code&gt;vercel.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"rewrites"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/dashboard/:path*"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"destination"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/index.html"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/settings"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"destination"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/index.html"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;List only your app's real route prefixes. A catch-all &lt;code&gt;"/(.*)"&lt;/code&gt; rewrite makes every unknown URL return 200, which Google can flag as a soft 404. If you do use it, add a catch-all "Not found" route in your app router that shows a not-found page with &lt;code&gt;&amp;lt;meta name="robots" content="noindex"&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Node version mismatch
&lt;/h3&gt;

&lt;p&gt;Vercel currently supports Node.js 24.x (the default) and 22.x. Node.js 20 was deprecated on October 1, 2026, so new deployments pinned to 20.x fail. Set the version in Project Settings → Build and Deployment, or add &lt;code&gt;"engines": { "node": "24.x" }&lt;/code&gt; to &lt;code&gt;package.json&lt;/code&gt; (this overrides the Project Settings value).&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why does it work in the v0/Bolt preview?&lt;/strong&gt; Previews run a dev server, which skips type checks and prerendering.&lt;br&gt;
&lt;strong&gt;Do I need to redeploy after adding env vars?&lt;/strong&gt; Yes. Existing deployments don't pick up new values.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related guides
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://unbreakkit.netlify.app/guides/vercel-env-vars-invalid-api-key.html" rel="noopener noreferrer"&gt;Invalid API key or undefined env vars on Vercel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://unbreakkit.netlify.app/guides/module-not-found-checklist-ai-code.html" rel="noopener noreferrer"&gt;Module not found: a checklist for AI-generated code&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://unbreakkit.netlify.app/guides/npm-eresolve-peer-dependency.html" rel="noopener noreferrer"&gt;npm ERESOLVE peer dependency errors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://unbreakkit.netlify.app/guides/works-in-preview-blank-page-production.html" rel="noopener noreferrer"&gt;Works in preview, blank page in production&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Still stuck?
&lt;/h2&gt;

&lt;p&gt;Paste your exact error into the free &lt;strong&gt;UnbreakKit Error Fixer&lt;/strong&gt; and get a plain-English cause, the fix, and a prompt to paste back into your AI tool: &lt;a href="https://unbreakkit.netlify.app/products/error-fixer.html" rel="noopener noreferrer"&gt;https://unbreakkit.netlify.app/products/error-fixer.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>vercel</category>
      <category>nextjs</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Stripe Checkout Succeeds but Your App Never Records the Payment: How to Fix It</title>
      <dc:creator>UnbreakKit</dc:creator>
      <pubDate>Fri, 30 Oct 2026 14:36:12 +0000</pubDate>
      <link>https://dev.to/unbreakkit/stripe-checkout-succeeds-but-your-app-never-records-the-payment-how-to-fix-it-3p9g</link>
      <guid>https://dev.to/unbreakkit/stripe-checkout-succeeds-but-your-app-never-records-the-payment-how-to-fix-it-3p9g</guid>
      <description>&lt;h2&gt;
  
  
  The error
&lt;/h2&gt;

&lt;p&gt;The customer pays, Stripe shows the payment as succeeded, but your database never updates and the user doesn't get access. Common messages in your logs or in Stripe's webhook delivery details:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;No signatures found matching the expected signature for payload. Are you passing the raw request body you received from Stripe?
Webhook Error: Webhook signature verification failed
400 Bad Request / 401 Unauthorized / 404 Not Found (webhook endpoint)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sometimes there's no error at all, because the app was never listening for the webhook in the first place.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it happens
&lt;/h2&gt;

&lt;p&gt;Stripe Checkout runs on Stripe's page. Your app only learns that a payment succeeded when Stripe sends a &lt;strong&gt;webhook&lt;/strong&gt; (an HTTP POST) to your server. AI-built apps often get one of these wrong:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access is unlocked from the &lt;code&gt;/success&lt;/code&gt; page instead of a webhook. If the user closes the tab before the redirect, nothing is recorded, and anyone who types &lt;code&gt;/success&lt;/code&gt; into the address bar gets the paid content for free.&lt;/li&gt;
&lt;li&gt;The webhook secret doesn't match the endpoint. The Stripe CLI, the test-mode endpoint and the live-mode endpoint each have a &lt;strong&gt;different&lt;/strong&gt; &lt;code&gt;whsec_...&lt;/code&gt; secret.&lt;/li&gt;
&lt;li&gt;The request body is parsed as JSON before the signature check. Stripe signs the exact raw bytes it sent, so any re-serialized body fails verification.&lt;/li&gt;
&lt;li&gt;The webhook endpoint isn't reachable: wrong URL, not deployed, blocked by auth middleware, or behind your host's password protection.&lt;/li&gt;
&lt;li&gt;The handler runs but can't write to the database (for example, it uses the Supabase anon key and Row Level Security blocks the insert).&lt;/li&gt;
&lt;li&gt;The handler doesn't know which user paid, because the checkout session was created without a user ID.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Fixes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Grant access only from a verified webhook, never from /success
&lt;/h3&gt;

&lt;p&gt;Treat the success page as a "thanks, we're confirming your payment" screen. Do the real work in the webhook handler when you receive &lt;code&gt;checkout.session.completed&lt;/code&gt; and the session's &lt;code&gt;payment_status&lt;/code&gt; is &lt;code&gt;paid&lt;/code&gt;. If you accept delayed payment methods (like bank debits), also handle &lt;code&gt;checkout.session.async_payment_succeeded&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The success page can then read the order status from &lt;strong&gt;your&lt;/strong&gt; database and show "Payment confirmed" once the webhook has done its job.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Attach the user to the checkout session
&lt;/h3&gt;

&lt;p&gt;When you create the session on your server, pass the user ID so the webhook knows who paid:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;stripe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;checkout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sessions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;payment&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;line_items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt; &lt;span class="na"&gt;price&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;price_123&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;quantity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;}],&lt;/span&gt;
  &lt;span class="na"&gt;success_url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/success?session_id={CHECKOUT_SESSION_ID}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;cancel_url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/pricing`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;client_reference_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;user_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Verify the signature with the raw body
&lt;/h3&gt;

&lt;p&gt;Read the body as text or raw bytes, then pass it straight to Stripe. Next.js App Router route handler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app/api/stripe/webhook/route.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;Stripe&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;stripe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;stripe&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Stripe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRIPE_SECRET_KEY&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;               &lt;span class="c1"&gt;// raw body, NOT req.json()&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;sig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;stripe-signature&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Stripe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Event&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;stripe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;webhooks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;constructEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;sig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;STRIPE_WEBHOOK_SECRET&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Webhook Error: &lt;/span&gt;&lt;span class="p"&gt;${(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;checkout.session.completed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt; &lt;span class="kd"&gt;as &lt;/span&gt;&lt;span class="nx"&gt;Stripe&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Checkout&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Session&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payment_status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;paid&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// mark the order paid for session.client_reference_id&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ok&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Express: register the webhook route with &lt;code&gt;express.raw({ type: 'application/json' })&lt;/code&gt; &lt;strong&gt;before&lt;/strong&gt; any global &lt;code&gt;express.json()&lt;/code&gt; middleware. Next.js Pages Router: turn off the body parser for that route (&lt;code&gt;export const config = { api: { bodyParser: false } }&lt;/code&gt;) and read the raw stream. Supabase Edge Functions (Deno): use &lt;code&gt;await req.text()&lt;/code&gt; and the async verifier &lt;code&gt;stripe.webhooks.constructEventAsync(...)&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Use the right webhook secret for each environment
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Local testing:&lt;/strong&gt; run &lt;code&gt;stripe listen --forward-to localhost:3000/api/stripe/webhook&lt;/code&gt;. The CLI prints its own &lt;code&gt;whsec_...&lt;/code&gt; secret; use that one in &lt;code&gt;.env.local&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Production:&lt;/strong&gt; in the Stripe Dashboard, open the webhook endpoint you created for your live URL and reveal its signing secret. Put it in your host's environment variables and redeploy.&lt;/li&gt;
&lt;li&gt;Test mode and live mode are separate. A test-mode secret won't verify live events, and a &lt;code&gt;sk_test_&lt;/code&gt; key can't read live sessions. Switch both the secret key and the webhook secret together when you go live.
### 5. Make sure Stripe can reach the endpoint
In the Stripe Dashboard, open the webhook endpoint and look at recent event deliveries. The response code tells you what went wrong:&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;404&lt;/code&gt;: the URL path is wrong, or the route isn't deployed.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;401&lt;/code&gt;/&lt;code&gt;403&lt;/code&gt;: auth middleware, a login redirect, or host password protection is blocking Stripe. Exclude the webhook route.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;400&lt;/code&gt;: usually signature verification (see steps 3 and 4).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;500&lt;/code&gt;: your handler crashed. Check your server logs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Return a &lt;code&gt;2xx&lt;/code&gt; quickly. In live mode, Stripe retries failed deliveries for up to three days, and you can resend an event from the Dashboard once it's fixed.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Let the webhook write to the database, and handle duplicates
&lt;/h3&gt;

&lt;p&gt;The webhook runs on your server without a logged-in user, so use a server-only credential (for Supabase, the service role or &lt;code&gt;sb_secret_...&lt;/code&gt; key, kept out of frontend code). Stripe can deliver the same event more than once, so record &lt;code&gt;event.id&lt;/code&gt; or the session ID and skip events you've already processed. That way a retry never grants access twice.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prompt to paste into your AI tool
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Payments succeed in Stripe but my app never records them. Move all fulfillment out of the /success page into a Stripe webhook route. Verify the signature with stripe.webhooks.constructEvent using the raw request body (not parsed JSON) and STRIPE_WEBHOOK_SECRET. Handle checkout.session.completed only when payment_status is "paid", find the user via client_reference_id, make the handler idempotent by storing event.id, and return 200 quickly. Don't change anything else.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Can I just check the session on the /success page instead?&lt;/strong&gt; Retrieving the session server-side with &lt;code&gt;session_id&lt;/code&gt; is fine for showing a confirmation, but don't make it the only path. Users close tabs, and webhooks still fire.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How do I test without real money?&lt;/strong&gt; Use test mode with &lt;code&gt;stripe listen&lt;/code&gt; and a test card, or run &lt;code&gt;stripe trigger checkout.session.completed&lt;/code&gt;. Before launch, many founders also make one small real purchase in live mode and refund it to confirm the live webhook works end to end.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why does it work locally but not in production?&lt;/strong&gt; Locally you're using the CLI's secret. Production needs the secret from the live endpoint in the Dashboard, set on your host, followed by a redeploy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Related guides
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="//vercel-env-vars-invalid-api-key.html"&gt;Invalid API key or undefined env vars on Vercel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//supabase-empty-data-no-error-rls.html"&gt;Supabase returns empty data with no error&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="//leaked-api-key-env-file-what-now.html"&gt;I leaked an API key or .env file: what now?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Still stuck?
&lt;/h2&gt;

&lt;p&gt;Paste your exact error into the free &lt;strong&gt;UnbreakKit Error Fixer&lt;/strong&gt; and get a plain-English cause, the fix, and a prompt to paste back into your AI tool: &lt;a href="https://unbreakkit.netlify.app/products/error-fixer.html" rel="noopener noreferrer"&gt;https://unbreakkit.netlify.app/products/error-fixer.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>stripe</category>
      <category>webdev</category>
      <category>javascript</category>
      <category>ai</category>
    </item>
    <item>
      <title>"Invalid API key" or undefined env vars on Vercel: how to fix it</title>
      <dc:creator>UnbreakKit</dc:creator>
      <pubDate>Sun, 18 Oct 2026 23:52:10 +0000</pubDate>
      <link>https://dev.to/unbreakkit/invalid-api-key-or-undefined-env-vars-on-vercel-how-to-fix-it-50ig</link>
      <guid>https://dev.to/unbreakkit/invalid-api-key-or-undefined-env-vars-on-vercel-how-to-fix-it-50ig</guid>
      <description>&lt;p&gt;Your app works on your machine. You deploy to Vercel and get one of these:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: supabaseUrl is required.
AuthApiError: Invalid API key
OpenAI API error: 401 Incorrect API key provided: undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Or &lt;code&gt;process.env.MY_KEY&lt;/code&gt; is simply &lt;code&gt;undefined&lt;/code&gt; in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it happens
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.env.local&lt;/code&gt; is &lt;strong&gt;not&lt;/strong&gt; deployed (it's git-ignored, as it should be). Vercel needs its own copy.&lt;/li&gt;
&lt;li&gt;The variable was added after the last deployment. Env vars only apply to &lt;strong&gt;new&lt;/strong&gt; deployments.&lt;/li&gt;
&lt;li&gt;It was added for the wrong environment (Production vs Preview vs Development).&lt;/li&gt;
&lt;li&gt;It's used in browser code without the &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; prefix (Next.js) or &lt;code&gt;VITE_&lt;/code&gt; prefix (Vite).&lt;/li&gt;
&lt;li&gt;Typos, quotes, or trailing spaces/newlines were pasted into the value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Fix 1: add the variables in Vercel, then redeploy
&lt;/h2&gt;

&lt;p&gt;Vercel â†’ Project â†’ Settings â†’ Environment Variables. Add each key, tick the environments that need it, then &lt;strong&gt;redeploy&lt;/strong&gt; (Deployments â†’ â‹¯ â†’ Redeploy). Or use the CLI:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vercel env add NEXT_PUBLIC_SUPABASE_URL production
vercel env pull .env.local   # pulls Development values (add --environment=production for prod)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Fix 2: use the right prefix for browser code
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Next.js: inlined at BUILD time, visible in the browser
const url = process.env.NEXT_PUBLIC_SUPABASE_URL!;

// Vite
const url = import.meta.env.VITE_SUPABASE_URL;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Public prefixes are baked in at build time, which is another reason a redeploy is required.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 3: keep secrets server-side
&lt;/h2&gt;

&lt;p&gt;Secret keys (&lt;code&gt;SUPABASE_SERVICE_ROLE_KEY&lt;/code&gt;, &lt;code&gt;OPENAI_API_KEY&lt;/code&gt;, &lt;code&gt;STRIPE_SECRET_KEY&lt;/code&gt;) must &lt;strong&gt;not&lt;/strong&gt; get a public prefix. Anything with &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; or &lt;code&gt;VITE_&lt;/code&gt; ends up in the JavaScript sent to every visitor. Use secrets only in Route Handlers, Server Actions or API routes:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// app/api/chat/route.ts
export async function POST(req: Request) {
  const key = process.env.OPENAI_API_KEY; // server only
  // ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Fix 4: fail fast with a clear message
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function requireEnv(name: string) {
  const v = process.env[name];
  if (!v) throw new Error(`Missing env var: ${name}`);
  return v;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For &lt;code&gt;NEXT_PUBLIC_&lt;/code&gt; variables in client code, reference them literally (&lt;code&gt;process.env.NEXT_PUBLIC_X&lt;/code&gt;). Dynamic lookups like &lt;code&gt;process.env[name]&lt;/code&gt; aren't inlined in the browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 5: check the value itself
&lt;/h2&gt;

&lt;p&gt;Re-copy the key from the provider dashboard. Remove quotes and trailing spaces. Make sure it's the key for the right project (for example, the Supabase anon or &lt;code&gt;sb_publishable_â€¦&lt;/code&gt; key in the client, never the service role or &lt;code&gt;sb_secret_â€¦&lt;/code&gt; key).&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;I added it but it's still undefined.&lt;/strong&gt; Did you redeploy? Is it ticked for Production?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is the Supabase anon key safe to expose?&lt;/strong&gt; It's designed to be public, but only if Row Level Security is enabled on your tables.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://unbreakkit.netlify.app/guides/vercel-env-vars-invalid-api-key.html" rel="noopener noreferrer"&gt;FixKit AI&lt;/a&gt;. Deploy failing for a different reason? See &lt;a href="https://unbreakkit.netlify.app/guides/v0-bolt-vercel-deploy-failed.html" rel="noopener noreferrer"&gt;why v0/Bolt apps fail on Vercel&lt;/a&gt;, or paste the error into the free &lt;a href="https://unbreakkit.netlify.app/products/error-fixer.html" rel="noopener noreferrer"&gt;FixKit Error Fixer&lt;/a&gt; (disclosure: I built it).&lt;/em&gt;&lt;/p&gt;

</description>
      <category>vercel</category>
      <category>nextjs</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Supabase RLS errors in Lovable and Bolt apps (and how to fix them safely)</title>
      <dc:creator>UnbreakKit</dc:creator>
      <pubDate>Sun, 18 Oct 2026 23:52:01 +0000</pubDate>
      <link>https://dev.to/unbreakkit/supabase-rls-errors-in-lovable-and-bolt-apps-and-how-to-fix-them-safely-2kkb</link>
      <guid>https://dev.to/unbreakkit/supabase-rls-errors-in-lovable-and-bolt-apps-and-how-to-fix-them-safely-2kkb</guid>
      <description>&lt;p&gt;If you built your app with Lovable or Bolt on top of Supabase, sooner or later you'll see this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;new row violates row-level security policy for table "todos"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;That's Postgres error code &lt;code&gt;42501&lt;/code&gt;. Its quieter cousin is worse: a &lt;code&gt;select&lt;/code&gt; that returns &lt;code&gt;[]&lt;/code&gt; with &lt;strong&gt;no error&lt;/strong&gt;, even though the table clearly has rows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why it happens
&lt;/h2&gt;

&lt;p&gt;When Row Level Security (RLS) is enabled and no policy allows an action, Supabase blocks it. Common causes in AI-built apps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;RLS is enabled but no &lt;code&gt;insert&lt;/code&gt;/&lt;code&gt;select&lt;/code&gt; policy exists&lt;/li&gt;
&lt;li&gt;The user isn't logged in, so &lt;code&gt;auth.uid()&lt;/code&gt; is null&lt;/li&gt;
&lt;li&gt;The insert doesn't set &lt;code&gt;user_id&lt;/code&gt;, or sets it to a different value&lt;/li&gt;
&lt;li&gt;An &lt;code&gt;update&lt;/code&gt; policy is missing its &lt;code&gt;with check&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Reads and writes fail differently. A blocked &lt;code&gt;select&lt;/code&gt; doesn't throw; rows are filtered out and you get &lt;code&gt;[]&lt;/code&gt;. A blocked &lt;code&gt;insert&lt;/code&gt; throws the error above.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fix 1: add owner-based policies
&lt;/h2&gt;

&lt;p&gt;Run this in the Supabase SQL editor (rename &lt;code&gt;todos&lt;/code&gt; to your table):&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alter table public.todos enable row level security;

&lt;p&gt;create policy "Users read own todos" on public.todos&lt;br&gt;
  for select to authenticated using ((select auth.uid()) = user_id);&lt;/p&gt;

&lt;p&gt;create policy "Users insert own todos" on public.todos&lt;br&gt;
  for insert to authenticated with check ((select auth.uid()) = user_id);&lt;/p&gt;

&lt;p&gt;create policy "Users update own todos" on public.todos&lt;br&gt;
  for update to authenticated&lt;br&gt;
  using ((select auth.uid()) = user_id) with check ((select auth.uid()) = user_id);&lt;/p&gt;

&lt;p&gt;create policy "Users delete own todos" on public.todos&lt;br&gt;
  for delete to authenticated using ((select auth.uid()) = user_id);&lt;br&gt;
&lt;/p&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Fix 2: fill in &lt;code&gt;user_id&lt;/code&gt; automatically&lt;br&gt;
&lt;/h2&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alter table public.todos alter column user_id set default auth.uid();&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Fix 3: make sure the user is actually signed in&lt;br&gt;
&lt;/h2&gt;
&lt;br&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { data: { user } } = await supabase.auth.getUser();&lt;br&gt;
if (!user) throw new Error('Not signed in');&lt;br&gt;
await supabase.from('todos').insert({ title, user_id: user.id });&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Don't "fix" it by disabling RLS or shipping the service_role key&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;service_role&lt;/code&gt; key (and the newer &lt;code&gt;sb_secret_...&lt;/code&gt; keys) bypasses RLS entirely. Keep it on the server only, never in frontend code. The browser should only use the anon or publishable key, and that key is only safe because RLS limits what it can do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prompt to paste into Lovable or Bolt
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Write Supabase RLS policies so authenticated users can only select, insert, update, and delete rows where user_id = auth.uid(). Don't disable RLS and don't use the service_role key in the client.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why do I get empty results instead of an error?&lt;/strong&gt; RLS filters &lt;code&gt;select&lt;/code&gt; results silently. With no policy, you get zero rows.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is a public read policy OK?&lt;/strong&gt; Yes, for genuinely public data: &lt;code&gt;for select to anon, authenticated using (true)&lt;/code&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://unbreakkit.netlify.app/guides/supabase-rls-errors-lovable-bolt.html" rel="noopener noreferrer"&gt;FixKit AI&lt;/a&gt;. If you're seeing a different error, paste it into the free &lt;a href="https://unbreakkit.netlify.app/products/error-fixer.html" rel="noopener noreferrer"&gt;FixKit Error Fixer&lt;/a&gt; (disclosure: I built it). Related: &lt;a href="https://unbreakkit.netlify.app/guides/cors-error-lovable-api.html" rel="noopener noreferrer"&gt;CORS errors when a Lovable app calls an API&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>supabase</category>
      <category>postgres</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
