Abbi Labs

Guides

CORS misconfiguration: is your API readable by any website? Test it in one request

By Abbi Labs · Last updated 20 November 2026

Built with Lovable, Bolt, Cursor or Replit?

The Abbi Labs quick check sends your home page a request from a foreign origin and preflights the API routes your JavaScript calls (OPTIONS only), and flags echoed origins, a trusted null origin, and * on routes that look authenticated. No sign-up for the quick check.

No app handy?

No sign-up. Read-only public-resource and protocol metadata checks. No model prompts or tool execution. Scan only sites you own or are allowed to test.

Run on every deploy or use from Cursor / Claude Code via MCP →

What goes wrong

CORS tells browsers which other websites may read responses from your site. AI builders often "fix" a CORS error by echoing back whatever Origin the request had, and add Access-Control-Allow-Credentials: true so cookies work. Together that means any website a signed-in user visits can call your API as them and read the answer: profile, orders, API keys.

Test your own site (1 minute)

curl -s -D - -o /dev/null -H "Origin: https://evil.example" https://yourapp.com/api/me
curl -s -D - -o /dev/null -X OPTIONS -H "Origin: null" \
  -H "Access-Control-Request-Method: GET" https://yourapp.com/api/me

If the response contains Access-Control-Allow-Origin: https://evil.example (or null) together with Access-Control-Allow-Credentials: true, fix it now. Only test sites you own.

The fix: an explicit allowlist

// Next.js middleware.ts (or a route handler)
const ALLOWED = (process.env.ALLOWED_ORIGINS ?? "https://yourapp.com,https://www.yourapp.com").split(",");
const origin = req.headers.get("origin");
const res = NextResponse.next();
res.headers.set("Vary", "Origin");
if (origin && ALLOWED.includes(origin)) {
  res.headers.set("Access-Control-Allow-Origin", origin);
  res.headers.set("Access-Control-Allow-Credentials", "true");
}
// never: res.headers.set("Access-Control-Allow-Origin", origin ?? "*") for every origin

// Express
app.use(cors({ origin: ALLOWED, credentials: true }));

// Supabase Edge Function: build corsHeaders from the allowlist, not from the request
const allow = ALLOWED.includes(req.headers.get("origin") ?? "") ? req.headers.get("origin")! : ALLOWED[0];

Fix it with AI

Paste this into Lovable, Bolt, Cursor or Replit:

My site's CORS is too open. Find every place that sets Access-Control-Allow-Origin (middleware, next.config headers, vercel.json, Express cors(), Supabase Edge Function corsHeaders). Replace any code that echoes the request Origin or allows "null" with an allowlist from an ALLOWED_ORIGINS env var (my production domain and www; localhost only in development). Only set Allow-Origin for allowlisted origins, add Vary: Origin, and only send Access-Control-Allow-Credentials: true for those origins. Keep * only for public, non-user data. Show me a curl test: Origin https://evil.example must not be echoed back, and my real site still works.

Keep it that way

CORS gets loosened during a late-night "blocked by CORS policy" fix. Abbi Labs re-scans your live app and alerts you when something changes: leaked keys, readable Supabase tables, exposed files, CORS, cookie flags and certificate expiry.

Run a free scan

FAQ

Is Access-Control-Allow-Origin: * dangerous?

Not by itself. Browsers never send cookies with *, so cookie-based sessions stay safe. It's a problem on routes that return private data without checking a token, or that trust the visitor's network. Use * for public data only.

Why is a reflected origin with credentials so bad?

Because the browser then sends the user's cookies to your API on behalf of the attacker's page and lets that page read the response. The attacker gets whatever your API returns to that user.

What does the Abbi Labs CORS check send?

One GET to your home page with Origin: https://evil-cors-probe.example, and an OPTIONS preflight (never a GET or POST) to up to three /api/ routes and two Supabase Edge Functions referenced in your JavaScript. If a specific origin comes back, it repeats the request once with Origin: null. Response bodies are never stored.

Supabase Edge Functions use * by default. Is that flagged?

No. Supabase's documented corsHeaders use *, and Edge Functions authenticate with a bearer token, so * there is reported as fine. Echoing the origin with credentials still is flagged.

Related

Weekly AI-app security checklist

One short email a week: a practical check for apps built with Supabase, Next.js and AI tools (RLS, leaked keys, headers and more). Unsubscribe anytime.