What it means
The 404 comes from Supabase's Functions gateway, before your code runs. Usually no function with that name is registered on the project in the URL; Supabase also documents NOT_FOUND when a function isn't available in a region yet (redeploy and wait), and NOT_FOUND_FUNCTION_BLOB returns the same body. The sb-error-code response header tells them apart. Because your function never ran, your CORS headers never got sent, and the browser reports it as a CORS error. Changing CORS code won't fix it.
Prove it in one minute
# your function
curl -i -X OPTIONS https://<project-ref>.supabase.co/functions/v1/my-function
# a name that surely doesn't exist
curl -i -X OPTIONS https://<project-ref>.supabase.co/functions/v1/does-not-exist-123If both return the same 404, the gateway doesn't know your function at that address.
The usual causes
- Name mismatch. The function name is the folder name under
supabase/functions/.capture-paypal-order,capture_paypal_orderandcapturePaypalOrderare three different functions. - Wrong project. Deployed to staging, but the app's
SUPABASE_URLpoints at production (or the other way round). The project ref in the URL decides where the request goes. - Renamed or deleted after the frontend was built, and the app still calls the old name.
List what is actually deployed on the project your app calls:
supabase functions list --project-ref <project-ref>If a test from the dashboard works but the browser gets 404, compare the exact URL in the browser's network tab with the names in that list.
Once the function is found: a CORS handler that works
const cors = {
'Access-Control-Allow-Origin': 'https://your-app.com',
'Access-Control-Allow-Headers': 'authorization, x-client-info, apikey, content-type',
'Access-Control-Allow-Methods': 'POST, OPTIONS',
};
Deno.serve(async (req) => {
if (req.method === 'OPTIONS') return new Response('ok', { headers: cors });
const data = { ok: true };
return new Response(JSON.stringify(data), {
headers: { ...cors, 'Content-Type': 'application/json' },
});
});Add the CORS headers to every response, including errors, or the browser hides the real error behind a CORS message again.
Related guides
- Supabase Edge Function CORS errors from the browser – headers, preflight and error responses
- Supabase Edge Function 401 “Invalid JWT” or “Missing authorization header”
- Supabase cron (pg_cron) job not running – a checklist with the SQL for each step
- Supabase Database Webhooks and pg_net requests that never arrive – how to debug them
More in Edge Functions, webhooks and APIs · all guides