Fix · Supabase and databases
CORS error when my website calls Supabase or an Edge Function
Blocks your work
What you may see
- The console says blocked by CORS policy
- A request works in a tool like Postman but not in the browser
Most likely cause
A browser asks the server first whether your website's address may call it; the server answered without the allow headers, or the real error hides behind the CORS message.
Check first (about two minutes)
- Open the browser network tab: is there an OPTIONS request first, and what status does it have?
- Check the real status of the second request: a 401, 404 or 500 often shows up as CORS.
The fix prompt
What you type here never leaves your browser. The search runs on this page, and nothing is sent to a server or to an AI.
Kept only in this browser, on this device. Keys and passwords are removed before anything is saved.
Prompt language
Paste it into Claude, ChatGPT, Gemini or Cursor, then follow what it says.
After you tried it, did it work?
Steps
- Find which address the browser calls and what the OPTIONS answer is.
- For Supabase's own data API, check the project address and keys are right (a wrong address looks like CORS).
- For an Edge Function or my own server route, add an OPTIONS handler and the allow headers (origin, headers, methods) to EVERY response, including errors.
- Allow only my site addresses, not a star for everyone.
Do not do this
- Do not set the allowed origin to * for functions that use cookies or private data.
- Do not install a browser extension that turns CORS off, as a fix.