StoicBuilder

HandbookIII the CastraCORS

IIIthe Castra, Stay in control

CORS

1 min readUpdated 28 November

In plain words

CORS is a browser rule: a page on one website can only read replies from another website's API if that API says the first site is allowed.

Where you see it

Your Lovable app calls a Supabase Edge Function and the console says "blocked by CORS policy: No 'Access-Control-Allow-Origin' header". The request often reached the server; the browser refused to let your page read the reply.

supabase/functions/share-note/index.tsserver
const corsHeaders = { "Access-Control-Allow-Origin": "https://quill.app", "Access-Control-Allow-Headers": "authorization, x-client-info, apikey, content-type",}; if (req.method === "OPTIONS") { return new Response("ok", { headers: corsHeaders });}
Name the site that may call you, and answer the browser's OPTIONS pre-check.

What goes wrong

  1. Allowing every website to silence the error

    A * origin trusts every site on the internet, which is rarely what you meant. Echoing back whatever origin asks while allowing cookies is worse.

    "Access-Control-Allow-Origin": "*"
  2. Thinking CORS protects your API

    Only browsers obey CORS. A script, curl or Postman ignores it completely, so your server still needs login and permission checks.

  3. Fixing it in the browser code

    The agent adds mode: "no-cors" to the fetch call. The error goes away and so does your data, because the reply comes back empty.

    fetch(url, { mode: "no-cors" })

What to tell your agent

Copy this into Lovable, Bolt, Cursor or any agent
Fix this CORS error on the server, not in the browser code: allow only my live domain and localhost, and answer the OPTIONS preflight request the browser sends first. Don't use a wildcard origin or mode: "no-cors", and tell me which header was missing.

Quick check

Sign in to earn +10 XP for it

Harbor's API has strict CORS settings. Can someone still call it with curl from their laptop?

Got a prompt that touches CORS?

Paste it. You get a better prompt first, then the cards that explain it.

Check your own prompt

Free, no sign-up.