You paste your AI's work onto a new domain, click the signup button, and the console turns red: "Blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present." You ask the AI to fix it. It changes the frontend, it changes the server, it adds a proxy, and eventually the error goes away. Most people leave it there.
That's a mistake, for two reasons. First, the fix the AI applies often opens your API to every website on the internet. Second, CORS is one of the few errors in AI-generated code where the "working" version and the dangerous version look identical from the outside. Both load your data. One of them also lets someone else's site load your data while the user is logged in.
This post explains what CORS actually checks, why AI tools get it wrong in a consistent way, and how to check which version your app has.
What CORS is actually for
Your app runs in a browser. The browser is the only place where an attacker can run code inside your user's session, so it's also the only place where the browser agrees to enforce rules on behalf of other servers. CORS is one of those rules.
When JavaScript on site A tries to fetch data from site B, the browser asks site B: do you allow this? Site B answers with response headers like Access-Control-Allow-Origin. If B says yes, or says nothing, the browser blocks the response and you see the red error.
So the red error usually means one of two things:
Your frontend and your API live on different domains, and the API hasn't said "my own frontend is allowed". This is the common, boring, fixable case.
The request your code is making shouldn't be allowed at all, and the browser just saved you.
The AI tends to treat every red CORS error as the first case. That's where the trouble starts.
The fix AIs reach for, and why it's a problem
Ask most AI coding tools to fix a CORS error and you'll get something like this on the server:
app.use(cors({ origin: '*' }));
That header tells every website in the world: you may read responses from this API. If your API serves public data, like a weather feed or a list of blog posts, that's fine. If your API serves anything tied to a user, like their orders, their messages or their account settings, it isn't.
The nastier version shows up when the AI combines a wildcard origin with cookies or login tokens:
app.use(cors({ origin: '*', credentials: true }));
Browsers refuse that combination outright, so the AI "fixes" the browser's complaint by echoing back whatever origin made the request:
app.use(cors({
origin: (origin, callback) => callback(null, true),
credentials: true
}));
This passes every test. Your frontend works. The error is gone. But the server now reflects any origin back as allowed, with credentials permitted. It is functionally the same as opening the API to everyone, with a few extra steps. A malicious site can make a logged-in user's browser request your API and read the response.
An AI wrote this pattern on a real project, tested it, declared it fixed, and moved on. It wasn't being careless. It optimised for the error message disappearing, which is exactly what it was asked to do.
What a correct setup looks like
The fix is almost always a short allowlist on the server. List the origins that genuinely need access, and refuse everything else.
For an Express server:
app.use(cors({
origin: ['https://yourapp.com', 'http://localhost:5173'],
credentials: true
}));
With that in place:
your own frontend works, because its origin is on the list
localhost works while you're developing
anyone else's site gets blocked, which is what you want
Supabase handles most of this for you, which is one reason it's popular with vibe coders. If you've built on Lovable or Bolt with Supabase behind it, your API is the Supabase API and it already answers CORS for your own domain. The CORS problems that remain in those stacks usually appear when someone adds a custom server, a Stripe webhook receiver, or a third-party API proxy in front of Supabase. Those additions are where AI-generated CORS config tends to land.
How to check what your app is currently doing
You don't need to read the server code to know. Open your app, log in, then run one check from a site you don't control. Here's the quick version:
Open your browser's devtools on your app and confirm a normal logged-in request to your API succeeds.
In a new tab, open any other website, open its console, and run a fetch against your API that requires being logged in, sending credentials.
Look at the result.
If the request succeeds from another site while you're logged in, your API is open. It doesn't matter that the CORS config in your code looks restrictive. The behaviour is the config.
If it fails with a CORS error, your API is locked down and the red error your users see is almost certainly the boring case: a missing entry on the allowlist, probably for a domain you added later, like a preview URL or a custom domain.
This five minute test is one of the checks in our free surface check, which you can run yourself at vibecodeguardian.co.uk/free-check.
The other red herring: "preflight" failures
Some CORS errors mention an "OPTIONS" request or a "preflight" response that failed. This happens when your request includes headers the browser considers unusual, most often an Authorization header or a custom header like Idempotency-Key.
The browser sends a quiet OPTIONS request first, asking the server which methods and headers it accepts. If the server doesn't answer OPTIONS at all, the real request never happens. AIs frequently fix this by stripping the custom header from the request instead of teaching the server to answer the preflight, which works until the feature that needed the header silently stops working in production.
If you hit a preflight error, the fix belongs on the server: respond to OPTIONS with the methods and headers you actually allow. Don't let the AI delete headers from your requests to make the error go away.
When to worry about CORS at all
It's worth being honest about severity. CORS misconfiguration is not the top reason AI-built apps leak data. In our audit, which tests apps against 137 points across 14 areas, missing database row security and exposed secrets are far more common findings than CORS problems. If you have one afternoon to spend on security, spend it on your database policies and your environment variables first.
CORS matters most in one specific situation: your API holds user-specific data, users stay logged in across sessions, and your server config lets any origin through with credentials. That combination turns any website your user visits into a way to read their data. If your app has payments, messages, or anything personal in it, the five minute test above is worth doing before launch.
If you'd rather have someone go through the whole list, our launch-readiness audit covers CORS, database rules, secrets, auth and the rest, with a plain-English report at the end. Options are on our packages page.