<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Ship-Ready]]></title><description><![CDATA[Ship-Ready]]></description><link>https://getshipready.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 21 Nov 2026 20:18:07 GMT</lastBuildDate><atom:link href="https://getshipready.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Supabase edge function returns 401 "Invalid JWT" after switching to the new API keys: the safe fix]]></title><description><![CDATA[Edge functions return 401 Invalid JWT after moving to sb_publishable keys? Here's the fix, plus the step that keeps your function from going public.]]></description><link>https://getshipready.hashnode.dev/supabase-edge-function-returns-401-invalid-jwt-after-switching-to-the-new-api-keys-the-safe-fix</link><guid isPermaLink="true">https://getshipready.hashnode.dev/supabase-edge-function-returns-401-invalid-jwt-after-switching-to-the-new-api-keys-the-safe-fix</guid><category><![CDATA[supabase]]></category><category><![CDATA[Security]]></category><category><![CDATA[lovable]]></category><category><![CDATA[webdev]]></category><category><![CDATA[Deno]]></category><dc:creator><![CDATA[Ship-Ready]]></dc:creator><pubDate>Thu, 19 Nov 2026 03:11:43 GMT</pubDate><content:encoded><![CDATA[<p>You switched your app from the old <code>eyJ…</code> anon key to the new <code>sb_publishable_…</code> key (Supabase retires the old keys by the end of 2026), and now your edge functions answer every call with:</p>
<pre><code>401 {"message":"Invalid JWT"}
</code></pre>
<p>Your function code never ran. The 401 comes from the platform, before your code.</p>
<h2>Why it happens</h2>
<p>Supabase's <a href="https://supabase.com/docs/guides/getting-started/migrating-to-new-api-keys">migration guide</a> explains it: if the new key is sent on the <code>Authorization: Bearer</code> header, "the platform tries to parse it as a JWT and rejects the request with Invalid JWT. The platform's built-in verify_jwt check only understands the legacy JWT-based keys, so set verify_jwt = false for these functions and authorize the request in your own code."</p>
<p>The <a href="https://supabase.com/kb/troubleshooting/edge-function-401-error-response">401 troubleshooting page</a> says the same: "Supabase now recommends turning off this built-in check and managing authentication directly in your function code, giving you more control over access."</p>
<h2>The trap: the official fix only does half the job</h2>
<p>Every fix you'll find says: set <code>verify_jwt = false</code>. That makes the 401 go away. It also removes the only thing that was stopping strangers from calling your function. Supabase's own words (<a href="https://supabase.com/docs/guides/functions/auth">Securing Edge Functions</a>): turning it off "to clear a 401 during development removes the platform's check, leaving withSupabase as the only thing that verifies the caller."</p>
<p>If your function has no check of its own (very common in code written by Lovable, Bolt or an AI agent), it is now public. Anyone with the URL can run it: send email through your account, spend your OpenAI or Lovable AI credit, or write to your database with the service key.</p>
<p>So the fix is two steps, always together.</p>
<h2>Step 1: turn off the legacy check, for that function only</h2>
<p>In <code>supabase/config.toml</code>:</p>
<pre><code>[functions.my-function]
verify_jwt = false
</code></pre>
<p>(or the toggle on the function's page in the Supabase dashboard). Don't turn it off for functions you haven't done Step 2 on.</p>
<h2>Step 2: check the caller inside the function</h2>
<p>Supabase's recommended way is the <code>@supabase/server</code> SDK. The migration guide: "Keep verify_jwt = false so the SDK does the authorization."</p>
<pre><code>import { withSupabase } from 'npm:@supabase/server@1'

Deno.serve(
  withSupabase({ auth: 'user' }, async (_req, ctx) =&gt; {
    // ctx.supabase is scoped to the signed-in user (RLS applies)
    return Response.json({ email: ctx.userClaims?.email })
  })
)
</code></pre>
<p>Pick the mode per function:</p>
<table>
<thead>
<tr>
<th>Who calls it</th>
<th><code>auth</code> mode</th>
<th>Note</th>
</tr>
</thead>
<tbody><tr>
<td>Your signed-in users (from the app)</td>
<td><code>'user'</code></td>
<td>Most app functions. Rejects anyone not logged in.</td>
</tr>
<tr>
<td>A cron job, another function, your backend</td>
<td><code>'secret'</code></td>
<td>Secret key on the <code>apikey</code> header. Never in the browser.</td>
</tr>
<tr>
<td>Anyone with your app (public data)</td>
<td><code>'publishable'</code></td>
<td>The publishable key is public, so this does not stop strangers. Add a rate limit.</td>
</tr>
<tr>
<td>Stripe or another webhook</td>
<td><code>'none'</code> + verify the signature</td>
<td>Check <code>stripe-signature</code> with <code>constructEventAsync</code> before doing anything.</td>
</tr>
</tbody></table>
<p>Not on the SDK? The older pattern still works: create a client with the caller's <code>Authorization</code> header, call <code>supabase.auth.getUser()</code>, and return 401 if there's no user.</p>
<h2>Also fix the client call</h2>
<p>The new keys aren't JWTs, so send them on the <code>apikey</code> header, not <code>Authorization: Bearer</code>. <code>supabase.functions.invoke()</code> from a signed-in session sends the user's JWT for you. Supabase's guide warns that a function passing the platform check "doesn't authenticate a caller that sends only an API key, so authorize the key in your handler."</p>
<h2>Check you didn't open anything</h2>
<ol>
<li><p>Search <code>supabase/config.toml</code> for <code>verify_jwt = false</code>. For each function listed, open its <code>index.ts</code> and confirm one of: <code>withSupabase({ auth: 'user' | 'secret' })</code>, <code>auth.getUser()</code>, or a webhook signature check before any work.</p>
</li>
<li><p>Call it with no headers at all:</p>
<pre><code>curl -i -X POST https://YOUR-PROJECT.supabase.co/functions/v1/my-function
</code></pre>
</li>
<li><p>Or run the free <a href="https://getshipready.github.io/lite.html">Ship-Ready quick scan</a> (offline, reads files only). Check AUTH-010 flags any function with <code>verify_jwt = false</code> and no caller check:</p>
<pre><code>python3 skills/ship-ready-quick-scan/scripts/quickscan.py path/to/app
</code></pre>
</li>
</ol>
<p>Related: <a href="https://getshipready.github.io/guides/supabase-legacy-api-keys-migration.html">Supabase is retiring the eyJ keys: the safe migration</a> · <a href="https://getshipready.github.io/guides/stripe-webhook-not-verified.html">Stripe webhook not verified</a> · <a href="https://getshipready.github.io/guides/supabase-anon-key-exposed.html">is my anon key a problem?</a></p>
<hr />
<p><em>Originally published on <a href="https://getshipready.github.io/guides/supabase-edge-function-invalid-jwt-new-keys.html">Ship-Ready guides</a>. The free <a href="https://getshipready.github.io/lite.html">Ship-Ready Lite</a> quick scan runs offline on your code and flags open edge functions (verify_jwt = false with no caller check), exposed keys, RLS-off tables, <code>using (true)</code> policies and unverified Stripe webhooks. Disclosure: I build Ship-Ready.</em></p>
]]></content:encoded></item><item><title><![CDATA[@supabase/server adapters are removed on December 1: migrate without making your endpoints public]]></title><description><![CDATA[Hono, H3, Elysia, NestJS adapters in @supabase/server go away 1 Dec 2026. withClaims instead of withRequiredClaims turns a 401 into a 200. Safe swap.]]></description><link>https://getshipready.hashnode.dev/supabase-server-adapters-are-removed-on-december-1-migrate-without-making-your-endpoints-public</link><guid isPermaLink="true">https://getshipready.hashnode.dev/supabase-server-adapters-are-removed-on-december-1-migrate-without-making-your-endpoints-public</guid><category><![CDATA[webdev]]></category><category><![CDATA[supabase]]></category><category><![CDATA[Security]]></category><category><![CDATA[hono]]></category><category><![CDATA[Node.js]]></category><dc:creator><![CDATA[Ship-Ready]]></dc:creator><pubDate>Wed, 18 Nov 2026 22:12:04 GMT</pubDate><content:encoded><![CDATA[<p>If your API uses <code>withSupabase</code> from <code>@supabase/server/adapters/hono</code> (or <code>/h3</code>, <code>/elysia</code>, <code>/nestjs</code>), you have until <strong>December 1, 2026</strong>. Supabase's <a href="https://supabase.com/changelog/supabase-server-adapters-deprecated">changelog</a>: "They will be removed from the package on December 1, 2026."</p>
<p>The migration is small. The risk is one step that looks right, compiles, and quietly makes a signed-in-only endpoint public. Supabase's <a href="https://supabase.com/docs/reference/server/frameworks">frameworks guide</a> says it plainly: "One step in that migration can open an endpoint up without an error."</p>
<h2>Are you affected?</h2>
<p>Search your code for <code>@supabase/server/adapters</code>. Every hit is a route group to move. Note the <code>auth</code> value on each <code>withSupabase(...)</code> call. Supabase: "A bare <code>withSupabase()</code> counts as <code>auth: 'user'</code>."</p>
<p>Not affected: <code>withSupabase(config, handler)</code> imported from <code>@supabase/server</code> itself, the pattern Supabase recommends for Edge Functions. The changelog: "<code>withSupabase(config, handler)</code> is not deprecated."</p>
<h2>The trap: withClaims is not a login check</h2>
<p>The replacement uses middleware "entries". Two of them look interchangeable and are not:</p>
<ul>
<li><code>withRequiredClaims()</code> rejects a request with no valid user token before your handler runs (401 <code>MISSING_CREDENTIALS</code>).</li>
<li><code>withClaims()</code> adds the caller's claims <em>if a token is there</em>. Supabase's <a href="https://supabase.com/docs/reference/server/middleware-withclaims">reference</a>: "<code>withClaims</code> is not an auth gate. It never rejects a request that has no token."</li>
</ul>
<p>The changelog: "Do not use <code>withClaims()</code> in place of <code>auth: 'user'</code>. The adapter rejected anonymous requests. <code>withClaims()</code> lets them through with <code>jwtClaims: null</code>, which turns a 401 into a 200 with no error."</p>
<p>Nothing breaks in testing (you're signed in), the typecheck passes, and the route now answers anyone. If the handler uses an admin client or reads by an id from the URL, that is a data leak.</p>
<h2>The safe swap</h2>
<table>
<thead>
<tr>
<th>Old adapter config</th>
<th>Use instead</th>
</tr>
</thead>
<tbody><tr>
<td><code>auth: 'user'</code>, or no config</td>
<td><code>withRequiredClaims()</code></td>
</tr>
<tr>
<td><code>auth: 'none'</code></td>
<td>nothing (client entries only)</td>
</tr>
<tr>
<td><code>auth: 'publishable'</code> or <code>auth: 'secret'</code></td>
<td>keep <code>withSupabase</code>; there is no bridge entry</td>
</tr>
</tbody></table>
<p>Hono example from Supabase's frameworks guide. First copy their <code>hono/supabase-middleware.ts</code> bridge into your project; it needs <code>@supabase/server</code> 1.6.0+ and Node 22+, with <code>@supabase/middleware</code> as a direct dependency.</p>
<pre><code>import { withRequiredClaims } from '@supabase/server/middleware/required-claims'
import { withSupabaseClient } from '@supabase/server/middleware/client'
import { toHono } from './lib/supabase-middleware.js'

const app = new Hono()
  .use('*', toHono([withRequiredClaims(), withSupabaseClient()]))
</code></pre>
<p>Then rename call sites. The adapter gave you <code>c.var.supabaseContext</code>; the entries give flat keys. <code>supabaseContext.userClaims.id</code> becomes <code>c.var.jwtClaims.sub</code>.</p>
<h2>Check it in one minute</h2>
<ol>
<li><p>After deploying, call every route that used to need a login, with no token:</p>
<pre><code>curl -i https://YOUR_API/todos
</code></pre>
<p>Expect <code>401</code> with code <code>MISSING_CREDENTIALS</code>. A <code>200</code> means the route is open. Run this only against your own API.</p>
</li>
<li><p>Grep for the trap:</p>
<pre><code>grep -rn "withClaims()" src/
</code></pre>
<p>Every hit should be a route that is meant to be public, or a handler that checks <code>jwtClaims</code> is not null and returns 401 itself.</p>
</li>
</ol>
<p>Related: <a href="https://getshipready.github.io/guides/supabase-edge-function-invalid-jwt-new-keys.html">Edge function 401 Invalid JWT after the new keys</a> (the <code>withSupabase</code> pattern that is not changing) · <a href="https://getshipready.github.io/guides/login-is-not-access-control.html">Login is not access control</a> · <a href="https://getshipready.github.io/guides/supabase-legacy-api-keys-migration.html">Supabase is retiring the eyJ keys</a></p>
<hr />
<p><em>Originally published on <a href="https://getshipready.github.io/guides/supabase-server-adapters-deprecated-withclaims.html">Ship-Ready guides</a>. The free <a href="https://getshipready.github.io/lite.html">Ship-Ready Lite</a> quick scan runs offline on your code and flags exposed keys, RLS-off tables, <code>using (true)</code> policies and unverified Stripe webhooks. Disclosure: I build Ship-Ready.</em></p>
]]></content:encoded></item><item><title><![CDATA[Supabase is retiring the eyJ keys: the safe migration]]></title><description><![CDATA[Supabase retires the legacy anon and service_role keys by end of 2026. Check if your Lovable, Bolt or Cursor app uses them, and swap in 10 minutes.]]></description><link>https://getshipready.hashnode.dev/supabase-is-retiring-the-eyj-keys-the-safe-migration</link><guid isPermaLink="true">https://getshipready.hashnode.dev/supabase-is-retiring-the-eyj-keys-the-safe-migration</guid><category><![CDATA[supabase]]></category><category><![CDATA[Security]]></category><category><![CDATA[lovable]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Ship-Ready]]></dc:creator><pubDate>Wed, 18 Nov 2026 07:14:06 GMT</pubDate><content:encoded><![CDATA[<p>If your app talks to Supabase with a long key that starts with <code>eyJ</code>, it's on the legacy <code>anon</code> or <code>service_role</code> keys, and Supabase says those are going away. The swap takes about 10 minutes. The risky part is the one an AI tool can get wrong: where the new <em>secret</em> key ends up.</p>
<h2>What Supabase announced</h2>
<p>Supabase's <a href="https://supabase.com/docs/guides/getting-started/api-keys">API keys docs</a> say it "is deprecating the <code>anon</code> and <code>service_role</code> keys by the end of 2026". The replacements are a publishable key (<code>sb_publishable_...</code>) for browsers and apps, and secret keys (<code>sb_secret_...</code>) for servers. The docs add: "If a tool, tutorial, or AI assistant tells you to copy a long key that begins with <code>eyJ</code>, it was written for the legacy keys."</p>
<p>The <a href="https://github.com/supabase/supabase/issues/42716">timeline on GitHub</a> has two dates that matter:</p>
<ul>
<li>Projects restored from a pause since 1 November 2025 no longer come back with the legacy keys, and new projects don't have them at all. A free project that paused and was resumed can break for this reason alone.</li>
<li>"Late 2026, TBC: Legacy API keys will be deleted": after that, apps that still use them stop working.</li>
</ul>
<h2>Already seeing "Legacy API keys are disabled" or "Invalid API key"?</h2>
<p>That usually means the project's legacy keys are switched off (or it was restored from a pause without them), while something still sends an <code>eyJ</code> key. The usual suspects are a cron job, a nightly import or a server script, rather than the main app. Do steps 2–4 for that caller. If you just need things working again while you migrate, re-activate the legacy keys in Settings → API Keys: Supabase says deactivation is reversible.</p>
<h2>Step 1: are you affected?</h2>
<pre><code class="language-bash"># in your project (Lovable: sync to GitHub first)
grep -rn "eyJ" src/ .env* 2&gt;/dev/null | grep -iv test
grep -rn "VITE_SUPABASE_ANON_KEY\|NEXT_PUBLIC_SUPABASE_ANON_KEY" . --include=*.env* --include=*.ts --include=*.tsx 2&gt;/dev/null
</code></pre>
<p>Also check the live site: open DevTools, search the loaded JavaScript (Ctrl+Shift+F / Cmd+Option+F) for <code>eyJ</code>. Newer Lovable projects already use <code>VITE_SUPABASE_PUBLISHABLE_KEY</code>; older ones use <code>VITE_SUPABASE_ANON_KEY</code>.</p>
<h2>Step 2: create the new keys</h2>
<p>In the Supabase dashboard: Settings → API Keys → "Publishable and secret API keys". If you see "Create new API keys", your project is still on legacy keys only. Per the <a href="https://supabase.com/docs/guides/getting-started/migrating-to-new-api-keys">migration guide</a>, creating them is safe: the legacy keys keep working alongside them until you turn them off.</p>
<h2>Step 3: swap the browser key, then rebuild</h2>
<pre><code class="language-bash"># .env (use the exact variable name your code reads)
VITE_SUPABASE_PUBLISHABLE_KEY=sb_publishable_...
</code></pre>
<p><code>VITE_</code> and <code>NEXT_PUBLIC_</code> values are baked in when the app is built, so changing the variable does nothing until you rebuild and republish. Supabase says the publishable key has the same low privileges as <code>anon</code>, so your Row Level Security policies behave the same.</p>
<h2>Step 4: the swap that leaks your database</h2>
<p>The secret key replaces <code>service_role</code> and, like it, bypasses Row Level Security. It belongs only in servers and Edge Functions (Supabase adds <code>SUPABASE_SECRET_KEYS</code> to the functions' environment). The mistake to watch for: an AI tool "fixing" a permission error by putting <code>sb_secret_...</code> in a <code>VITE_</code> or <code>NEXT_PUBLIC_</code> variable.</p>
<p>Supabase's docs say secret keys return HTTP 401 when used from a browser, matched on the <code>User-Agent</code> header. That blocks browsers, not scripts: the key is still in your public bundle for anyone to copy. Check the build:</p>
<pre><code class="language-bash">npm run build
grep -rlE "sb_secret_|service_role" dist/ .next/static/ build/ 2&gt;/dev/null
</code></pre>
<p>Any hit: move that call into an Edge Function or server route, then rotate the key in the dashboard. Deleting the line isn't enough; it's still in git history and old deploys.</p>
<h2>Step 5: before you turn the old keys off</h2>
<p>Supabase's migration guide says there's no automatic usage indicator (its <a href="https://supabase.com/docs/guides/auth/signing-keys">signing keys FAQ</a> mentions "last used" indicators on the API Keys page, so look there too, but don't rely on it alone). Check every place that holds a key, including CI/CD and deploy scripts, webhooks and third-party integrations, cron jobs, workers and <code>pg_net</code> calls, and mobile builds already in users' hands. Deactivating the legacy keys in Settings → API Keys is reversible if you missed one.</p>
<h2>New key, same holes</h2>
<p>Swapping keys changes nothing about who can read what. If a table was readable with the <code>anon</code> key, it's readable with the publishable key too. While you're in there, run the <a href="https://getshipready.github.io/guides/supabase-anon-key-exposed.html">5-minute anon-key check</a> and the <a href="https://getshipready.github.io/guides/rls-second-user-test.html">second-user test</a>.</p>
<p>Related: <a href="https://getshipready.github.io/guides/supabase-42501-permission-denied.html">42501 permission denied after the Oct 30 change</a> · <a href="https://getshipready.github.io/guides/supabase-anon-key-exposed.html">is my anon key a problem?</a></p>
<hr />
<p><em>Originally published on <a href="https://getshipready.github.io/guides/supabase-legacy-api-keys-migration.html">Ship-Ready guides</a>. The free <a href="https://getshipready.github.io/lite.html">Ship-Ready Lite</a> quick scan runs offline on your code and flags service or secret keys in public env vars, RLS-off tables and <code>using (true)</code> policies. Disclosure: I build Ship-Ready.</em></p>
]]></content:encoded></item><item><title><![CDATA[Supabase 42501 "permission denied for table" after the Oct 30 change: the safe fix]]></title><description><![CDATA[Your app worked yesterday. You (or your AI tool) added a new table, and now every request to it fails with 42501. Nothing is broken. Supabase changed a…]]></description><link>https://getshipready.hashnode.dev/supabase-42501-permission-denied-for-table-after-the-oct-30-change-the-safe-fix</link><guid isPermaLink="true">https://getshipready.hashnode.dev/supabase-42501-permission-denied-for-table-after-the-oct-30-change-the-safe-fix</guid><category><![CDATA[supabase]]></category><category><![CDATA[PostgreSQL]]></category><category><![CDATA[Security]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[Ship-Ready]]></dc:creator><pubDate>Wed, 18 Nov 2026 02:03:18 GMT</pubDate><content:encoded><![CDATA[<p>Your app worked yesterday. You (or your AI tool) added a new table, and now every request to it fails with <code>42501</code>. Nothing is broken. Supabase changed a default, and the fix takes one minute. But the fix the error suggests isn't always the one you want.</p>
<h3>Why it started</h3>
<p>Supabase <a href="https://supabase.com/changelog/45329-breaking-change-tables-not-exposed-to-data-and-graphql-api-automatically">announced on April 28, 2026</a> that new tables in the <code>public</code> schema are no longer exposed to the Data API automatically. It became the default for new projects from May 30, and was applied to all existing projects on <strong>October 30, 2026</strong>.</p>
<p>Before, every new table was granted to <code>anon</code>, <code>authenticated</code> and <code>service_role</code> the moment it was created. Now a new table needs an explicit <code>GRANT</code> before <code>supabase-js</code> can reach it. Existing tables keep their grants. Apps that connect to Postgres directly (psql, an ORM, a server with a connection string) aren't affected.</p>
<p>The error looks like this:</p>
<pre><code class="language-sql">{
"code": "42501",
"message": "permission denied for table your_table",
"hint": "Grant the required privileges to the current role with: GRANT SELECT ON public.your_table TO anon;"
}
</code></pre>
<h3>The trap: pasting the hint as-is</h3>
<p>The hint names the role that made the failing request. If your app called the table before anyone signed in, that role is <code>anon</code>: anyone on the internet holding your public key. A grant only decides whether a role can touch the table at all. <strong>Row-level security decides which rows it gets.</strong> So:</p>
<ul>
<li><p>Grant to <code>anon</code> on a table with RLS <strong>off</strong>: the whole table is readable by anyone.</p>
</li>
<li><p>Grant to <code>anon</code> with a <code>using (true)</code> policy: same result.</p>
</li>
<li><p>Asking an AI tool to "fix the permission error" can produce a bulk <code>grant ... on all tables in schema public to anon, authenticated</code>. That re-opens every table, including the private ones you never meant to expose.</p>
</li>
</ul>
<h3>The safe fix, in order</h3>
<p>Supabase's own guidance is to treat grant, RLS and policy as one unit. For a table that holds per-user data:</p>
<pre><code class="language-sql">-- 1. Grant only the roles that need it (signed-in users, not anon)
grant select, insert, update, delete on public.your_table to authenticated;

-- 2. Turn on row-level security
alter table public.your_table enable row level security;

-- 3. Say which rows each user gets
create policy "owner can read" on public.your_table
for select to authenticated using (auth.uid() = user_id);
create policy "owner can write" on public.your_table
for insert to authenticated with check (auth.uid() = user_id);
</code></pre>
<p>Grant to <code>anon</code> only for genuinely public data (a product catalogue, published posts), and pair it with a <code>select</code>-only policy. Never grant <code>insert</code>, <code>update</code> or <code>delete</code> to <code>anon</code> unless you mean "anyone can write here".</p>
<h3>If sign-up broke: "Database error saving new user"</h3>
<p>A 42501 during sign-up is a different problem, and a grant to <code>anon</code> or <code>authenticated</code> won't fix it. Supabase Auth writes new users as its own role, <code>supabase_auth_admin</code>. If a trigger on <code>auth.users</code> copies each new user into your <code>profiles</code> table, that trigger runs as the Auth role and gets refused. <a href="https://supabase.com/docs/guides/troubleshooting/dashboard-errors-when-managing-users-N1ls4A#solution-for-trigger-related-issues">Supabase's fix</a> is to make the trigger function <code>security definer</code>, pin its search path, and write table names in full:</p>
<pre><code class="language-sql">create or replace function public.handle_new_user()
returns trigger language plpgsql
security definer set search_path = ''
as $$
begin
insert into public.profiles (id) values (new.id);
return new;
end;
$$;
</code></pre>
<p>Check the Auth logs first: Supabase's <a href="https://supabase.com/docs/guides/troubleshooting/database-error-saving-new-user-RU_EwB">troubleshooting page</a> lists other causes too, like a missing table or an unmet constraint.</p>
<h3>If the error happens for signed-in users</h3>
<p>If the hint says <code>TO authenticated</code>, the user is signed in and only the grant is missing. Run step 1 for <code>authenticated</code>. If the request still fails, or returns no rows, the policy is the problem. See <a href="https://getshipready.github.io/guides/supabase-insert-success-no-row.html">insert "works" but no row appears</a>.</p>
<h3>Check you didn't open it up</h3>
<p>After the fix, open your live app in a private window, signed out, and confirm the new table's data doesn't load. Then run the <a href="https://getshipready.github.io/guides/rls-second-user-test.html">second-user test</a>: sign in as account B and try to read account A's rows. In the Table Editor, Supabase's Data API exposure badge and the Security Advisor also list tables worth reviewing.</p>
<h3>Catch it in the repo</h3>
<p>The free <a href="https://getshipready.github.io/lite.html">Ship-Ready quick scan</a> runs offline on your code and flags tables with RLS off and <code>using (true)</code> policies in your migrations, the two cases where an <code>anon</code> grant leaks data.</p>
<p>Related: <a href="https://getshipready.github.io/guides/supabase-anon-key-exposed.html">is my anon key a problem?</a> · <a href="https://getshipready.github.io/guides/rls-second-user-test.html">test your Supabase app as a second user</a> · <a href="https://getshipready.github.io/guides/supabase-view-bypasses-rls.html">views that bypass RLS</a></p>
<hr />
<p><em>Originally published at <a href="https://getshipready.github.io/guides/supabase-42501-permission-denied.html">getshipready.github.io</a>. I maintain Ship-Ready, a free MIT set of launch-safety checks for AI-built apps.</em></p>
]]></content:encoded></item></channel></rss>