VibeFix

Guide

No API key found in request (Supabase)

Published by Yosef D., founder of VibeFix

How this guide was made: Written with AI assistance and checked against the sources linked on this page.

Updated

You see this in the browser, in a network response or in your logs:

Get it fixed: a free check first confirms the problem on your live app, usually in 4 to 10 minutes.

Free. No account needed. It usually takes 4 to 10 minutes.

Want it fixed? Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.

{"message":"No API key found in request","hint":"No `apikey` request header or url param was found."}

The short answer

Supabase got a request with no project key attached. Every call to https://<project_ref>.supabase.co must carry your publishable (or legacy anon) key in an apikey header. The usual culprits are a hand-written fetch call, a server job or webhook that skips the header, or a login email that sends users to the supabase.co address instead of your app.

What it means

Your Supabase project sits behind a gateway. Before a request reaches the database, storage or auth, the gateway looks for a key in the apikey header (or an apikey URL parameter). If it finds none, it stops the request right there and sends back this message. So start with the request itself, not your tables or policies: something sent a request without the key.

The official Supabase client (createClient) adds the header for you on every call. So if you see this error, the failing request came from somewhere other than the Supabase client, or a user opened a Supabase address directly in their browser.

Causes

CauseHow to tellFix
A hand-written fetch or axios call to /rest/v1, /storage/v1, /auth/v1 or /functions/v1Open DevTools > Network, click the failing request to *.supabase.co. Under Request Headers there is no apikey line.Add the apikey header (step 2), or switch the call to the Supabase client (step 3).
Header sent under the wrong nameThe request has x-api-key, api-key or only Authorization, but no apikeyRename it to exactly apikey (step 2).
Users land on your supabase.co address after clicking a sign-up, invite or reset emailThe browser shows https://<ref>.supabase.co/#access_token=... with this JSON on screenSet Site URL and Redirect URLs to your app's domain (step 4).
Site URL saved without https://Authentication > URL Configuration shows yourapp.com instead of https://yourapp.com, and email links stop on the supabase.co addressAdd the protocol to Site URL (step 4).
A cron job, database webhook, pg_net call or outside service calls your Edge Function or REST API without a keyError shows in Edge Function or API logs, not in the browser. The call comes from SQL, a scheduler or a third-party tool.Add the key to that caller's headers (step 5).
Someone pasted a Supabase API URL into the address bar to test itHappens only when visiting the URL directly; the app itself worksExpected. Test with the command in "How to verify" instead.

Fix steps

1. Find the request that fails

  1. Open your live app in Chrome, press F12 and go to the Network tab.
  2. Reproduce the error.
  3. Type supabase.co in the Network filter box.
  4. Click the request whose response shows this message. Note its URL and look at Request Headers.

If the request has no apikey header, search your code for that URL path (for example rest/v1 or functions/v1) to find where it is built.

2. Add the apikey header to a hand-written call

Get the key from the Supabase dashboard under Settings > API Keys. In the browser, use only the publishable key (sb_publishable_...) or the legacy anon key. Never put a secret key (sb_secret_...) or service_role key in browser code.

Store it in an environment variable your build tool exposes to the browser:

# Vite / React apps

VITE_SUPABASE_URL=https://<project_ref>.supabase.co
VITE_SUPABASE_PUBLISHABLE_KEY=sb_publishable_xxxxxxxx

# Next.js

NEXT_PUBLIC_SUPABASE_URL=https://<project_ref>.supabase.co
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=sb_publishable_xxxxxxxx

Then send the key on every call:

const url = import.meta.env.VITE_SUPABASE_URL;               // Next.js: process.env.NEXT_PUBLIC_SUPABASE_URL
const key = import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY;   // Next.js: process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY

const res = await fetch(`${url}/rest/v1/todos?select=*`, {
  headers: {
    apikey: key,
  },
});

If the user is signed in and your RLS policies depend on who they are, also send their access token:

const { data: { session } } = await supabase.auth.getSession();
const headers = { apikey: key };
if (session) headers.Authorization = `Bearer ${session.access_token}`;
const res = await fetch(`${url}/rest/v1/todos?select=*`, { headers });

Add the same variables in your hosting provider's environment settings, then redeploy. Vite and Next.js put these values into the browser code at build time, so a new value only appears after a fresh build.

3. Or replace the hand-written call with the Supabase client

The client sends the key for you, so this error goes away for every call it makes:

import { createClient } from '@supabase/supabase-js';

export const supabase = createClient(
  import.meta.env.VITE_SUPABASE_URL,
  import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY
);

// Database
const { data, error } = await supabase.from('todos').select('*');

// Edge Function
const { data: result, error: fnError } = await supabase.functions.invoke('hello', {
  body: { foo: 'bar' },
});

If the key variable is empty, createClient stops with supabaseKey is required. instead. That points to a missing environment variable on your host, not this error.

4. Fix auth emails that land on the supabase.co address

  1. In the Supabase dashboard open Authentication > URL Configuration.
  2. Set Site URL to your live app address, including https://, for example https://yourapp.com. The default is http://localhost:3000. A Site URL saved without the protocol is a cause reported in the Supabase community thread on this error.
  3. Under Redirect URLs, add every address your app redirects to, for example https://yourapp.com/**.
  4. If your code passes a redirect, make sure it points at your app, not at Supabase:
await supabase.auth.signUp({
  email,
  password,
  options: { emailRedirectTo: 'https://yourapp.com/auth/callback' },
});

await supabase.auth.resetPasswordForEmail(email, {
  redirectTo: 'https://yourapp.com/update-password',
});

Get it fixed: a free check first confirms the problem on your live app, usually in 4 to 10 minutes.

Free. No account needed. It usually takes 4 to 10 minutes.

Want it fixed? Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.

  1. Check Authentication > Email Templates for any link that was hard-coded to https://<ref>.supabase.co.

Send yourself a new email after saving. Links in emails sent before the change still use the old address.

5. Add the key to server jobs, webhooks and Edge Function callers

For a pg_net call from SQL (for example inside a pg_cron job), keep the key in Vault and send it in the headers. This follows the pattern in the Supabase scheduling docs:

-- run once
select vault.create_secret('https://<project_ref>.supabase.co', 'project_url');
select vault.create_secret('sb_secret_xxxxxxxx', 'secret_key');

-- the call
select net.http_post(
  url := (select decrypted_secret from vault.decrypted_secrets where name = 'project_url') || '/functions/v1/function-name',
  headers := jsonb_build_object(
    'Content-type', 'application/json',
    'apikey', (select decrypted_secret from vault.decrypted_secrets where name = 'secret_key')
  ),
  body := '{"hello": "world"}'::jsonb
) as request_id;

The Edge Function then has to accept a secret key on apikey. Per the Supabase Edge Function auth docs, set this in supabase/config.toml and use auth: 'secret' in the function:

[functions.function-name]
verify_jwt = false

Without that setup, the function itself can still reject the call. Also note that any database role that can log in can read the key while pg_net holds the request in its queue.

For any other server or outside tool (Zapier, Make, n8n, your own backend), add a header named apikey with your key to the HTTP request settings. A secret key is fine here because it stays on the server. Keep it out of anything that runs in the browser.

How to verify it's fixed

  1. Test the key from a terminal. Replace the project ref, key and a real table name:
curl "https://<project_ref>.supabase.co/rest/v1/todos?select=*&limit=1" \
  -H "apikey: sb_publishable_xxxxxxxx"

You should get a JSON array (it can be [] if RLS hides rows), not the "No API key found" message. Run it once without the -H line and you should see the error again. That proves the header is what matters.

  1. Reload your live app with DevTools open. The request that failed in step 1 should now show an apikey request header and a 200 status.
  2. If the problem was an auth email, sign up or request a password reset with a fresh address and click the new link. You should land on your own domain, signed in.
  3. If the problem was a cron job or webhook, run it once and check Edge Functions > Logs (or the API logs) for a successful call.

FAQ

Is it safe to put the key in my frontend code?

The publishable key (sb_publishable_...) and the legacy anon key are designed to be public. Your Row Level Security policies decide what they can read or write. The secret key and service_role key skip RLS, so they must stay on the server only.

Supabase docs show ?apikey= in the URL. Should I use that?

The gateway accepts the key as a URL parameter, which is handy for a quick test. For app code, use the header: URLs end up in browser history, server logs and shared links.

My app worked yesterday and nothing changed. Why now?

Look at what calls Supabase outside the client: a new fetch added in a recent change, a scheduled job, a webhook from another service, or auth emails sent after someone edited Site URL. Step 1 shows you which request is missing the key.

Still stuck? Run the free VibeFix check on your live app, and if you want it fixed, the VibeFix AI agent finds the cause, fixes it in your code and re-checks the live app for $79.

Can VibeFix fix it for me?

Yes, for apps built in Lovable or any app whose code is on GitHub. The free check confirms the problem on your live app first. If you want it fixed, our AI agent finds the cause, fixes it in your code for $79 and tests your live app again. See pricing.

Sources

Last checked: 16 November 2026.

VibeFix is independent. Supabase and Stripe are trademarks of their owners.

Want it fixed?

Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.

It starts with a free check that confirms the problem on your live app, no account needed.

Check my app free

More guides · Shopify store accessibility · About · Your privacy choices