Guide · CORS · Updated
CORS for vibe-coded apps: wildcards, reflected origins and credentials, tested and fixed
Rather check your own app first and read later? Paste its address, prove it’s yours, and the free scan shows you the worst thing a stranger can reach. Run the free scan
If you’ve built an app with an AI tool, you’ve probably met the red line in the console that says something was “blocked by CORS policy.” You paste it back into the chat, a header gets added, the error goes away, and you move on to the next thing. Fair enough. But the change that makes a CORS error disappear fastest is to tell the browser that every website is welcome, and once cookies are involved, that can let any site your users visit read their account. This guide is the plain version: what CORS actually does, one curl command that shows what your app tells a stranger’s site, and how to fix it in Next.js, Supabase Edge Functions, Express, and on Vercel and Netlify.
New to this? Start with our vibe coding security checklist, eleven checks for any AI-built app. CORS is check 8 there. This page is the long version.
What we tested, and how
Everything on this page we ran ourselves on 25 October 2026, on our own machine. We built a small API with Express 5.3 and the cors package (2.8.6), with one route per setup you’ll see below, and a sign-in route that sets cookies. Then we put a stranger’s page on a second address. We used localhost for the API and 127.0.0.1 for the stranger, which Chrome treats as two different sites, signed in to the API in headless Chrome 155, opened the stranger’s page and recorded what it could read. The Next.js code ran in a production build of Next.js 16.4.3. The Supabase code ran in Node with @supabase/supabase-js 2.118.0 and @supabase/server 1.9.2, not on Supabase itself. We didn’t test on Vercel, Netlify or Supabase accounts. What we say about them comes from their docs, linked at the bottom.
The eight checks
- Know what CORS does, and what it doesn’t
- Ask your API what it tells a stranger’s site
- Access-Control-Allow-Origin: *, and when it’s fine
- An API that says yes to every origin it hears
- Cookies plus an open origin: the one that leaks accounts
- Allowlists that let in more than you meant
- Fix it with one exact list, where your code runs
- Test again, and keep it from coming back
01
Know what CORS does, and what it doesn’t
Browsers keep websites apart. A page on one site can send requests to another, but its JavaScript can’t read the answers. MDN calls this the same-origin policy, and an origin is the scheme, host and port together: https://yourapp.com and https://www.yourapp.com are two different origins.
CORS is how your server makes exceptions. The browser tells your API which page is asking, in an Origin header, and your API answers with Access-Control-Allow-Origin to say who may read the response. If the answer doesn’t name the asking site, or say *, the browser hides it from that site’s code. That’s the whole job.
What it doesn’t do surprises a lot of people, so here it is straight from the cors package docs: “CORS is not access control. Any HTTP client (curl, Postman, another server) can call your API regardless of CORS settings.” Your server still receives and runs every request. In our lab, when Chrome blocked the stranger’s page from reading an answer, our server log still showed the request arriving with the user’s cookie on it. Chrome only hid the response. So CORS never replaces checking who is asking on every route.
It doesn’t stop cross-site request forgery either. MDN explains that some requests skip the browser’s permission check entirely, because an HTML form could always send them, so “anyone writing a server must already be protecting against cross-site request forgery (CSRF).” PortSwigger’s CORS guide says the same in one line: “CORS is not a protection against cross-origin attacks such as cross-site request forgery (CSRF).”
What it does protect is the thing that matters most here: what another website can read out of your users’ browsers while they’re signed in to your app. That’s where the mistakes in this guide hurt.
One more thing before testing. If your pages and your API live on the same address, which is how most Next.js, v0 and Replit apps work, the browser never needs a CORS header at all. Lovable and Bolt apps mostly talk to Supabase directly, so the CORS you control there is on your Edge Functions.
02
Ask your API what it tells a stranger’s site
You don’t need a browser to see your CORS answer. Send a request that claims to come from somewhere else and look at the headers that come back. This tries four origins: a stranger, null (what sandboxed frames and local files send), a lookalike that starts with your domain, and one that ends with it.
# Put your domain in D, and in U an API route your front end calls.
D=yourapp.com
U=https://$D/api/me
for o in https://evil.example null https://$D.evil.example https://not$D; do
echo "== Origin: $o"
curl -s -o /dev/null -D - -H "Origin: $o" "$U" \
| grep -iE "^access-control-allow-(origin|credentials)"
donePick a route your front end really calls, ideally one that answers without signing in, because some setups only add CORS headers to successful responses. Then ask the question a browser asks before sending JSON, called a preflight:
# The question a browser asks before a POST with JSON
curl -s -o /dev/null -D - -X OPTIONS "$U" \
-H "Origin: https://evil.example" \
-H "Access-Control-Request-Method: POST" \
-H "Access-Control-Request-Headers: content-type" \
| grep -iE "^(HTTP/|access-control-|vary)"How to read what comes back:
- Nothing printed for any of the four. The best answer for an app whose pages and API share one address. That’s what lockship.dev returned when we ran it on 25 October.
access-control-allow-origin: *and no credentials line. Any site may read what a signed-out visitor can see. Often fine. Check 3.- Your fake origin repeated back to you. Your API says yes to everyone by name. Check 4.
- Repeated back, or
null, together withaccess-control-allow-credentials: true. Fix this today. Check 5. - Only
access-control-allow-credentials: true, with no allow-origin line. Harmless. Without an allow-origin line the browser shares nothing, and the cors package sends exactly this to origins that aren’t on its list when credentials are turned on.
This is what our test route with cors({ origin: true, credentials: true }) said to all four:
== Origin: https://evil.example
Access-Control-Allow-Origin: https://evil.example
Access-Control-Allow-Credentials: true
== Origin: null
Access-Control-Allow-Origin: null
Access-Control-Allow-Credentials: true
== Origin: https://yourapp.com.evil.example
Access-Control-Allow-Origin: https://yourapp.com.evil.example
Access-Control-Allow-Credentials: true
== Origin: https://notyourapp.com
Access-Control-Allow-Origin: https://notyourapp.com
Access-Control-Allow-Credentials: trueRun it once per API you have: your own /api routes, a separate backend if your front end calls one, and each Supabase Edge Function URL.
03
Access-Control-Allow-Origin: *, and when it’s fine
Access-Control-Allow-Origin: * means any site’s JavaScript may read the response, but only for requests sent without cookies. MDN’s reference is clear on both halves: “For requests without credentials, the literal value * can be specified as a wildcard,” and “Attempting to use the wildcard with credentials results in an error.” So a stranger’s page gets what anyone gets without signing in.
We saw exactly that. With cookies left out, the stranger’s page read our wildcard route and got a signed-out answer. With cookies included, Chrome refused:
Access to fetch at 'http://localhost:4100/wild' from origin 'http://127.0.0.1:4200'
has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header
in the response must not be the wildcard '*' when the request's credentials mode is 'include'.That makes * fine for public things: a product list, a public JSON feed, fonts, an open API. Vercel’s CORS guide says it plainly: * “is fine for public, unauthenticated APIs.” It’s also the default in a lot of examples you’ll copy from. The cors package’s default is origin: "*", Next.js shows * in its route handler and next.config headers examples, the second with a comment saying “Set your origin,” and Supabase’s Edge Function headers use it too.
Where it goes wrong is as a blanket rule. OWASP’s HTML5 cheat sheet advises using the header “only on chosen URLs that need to be accessed cross-domain. Don’t use the header for the whole domain.” A * on every route also covers the ones that return private data in some way you forgot about, and it’s one hurried edit away from check 4. When cookies stop working with *, the next change people make is to echo the origin back instead.
Our scan reports * without credentials as low: “CORS allows any origin” on your homepage, or “An API route allows any origin” on an API route. We used to call it medium and changed our minds, partly because our own site set us straight. The badge we hand out at /api/badge sends * on purpose, since it has to load on other people’s sites, and our scan flagging that as medium was just wrong. Without cookies, a stranger’s page gets what anyone gets by opening the URL. The one case where it really bites is a route that hands out private data because of where the request comes from rather than who’s signed in: an IP allowlist, an office VPN, something only reachable on an internal network. A visitor’s browser is inside that wall, so with * any site they open can read it. If none of your routes work like that, leave it. If you don’t need cross-site reads at all, delete the header.
04
An API that says yes to every origin it hears
Reflection is when the server copies whatever arrives in the Origin header into Access-Control-Allow-Origin. In the cors package that’s origin: true, which its docs describe as reflecting “the request origin”. By hand, it’s a line like res.setHeader("Access-Control-Allow-Origin", req.headers.origin).
It usually arrives as a fix. Chrome won’t accept * when cookies are sent, the error says so, and naming the asking site makes the error go away. The rule MDN describes is that a response to a request with cookies must name an explicit origin. Echoing every origin follows the letter of that rule and throws away the point of it. PortSwigger’s advice is blunt: “dynamically reflecting origins from cross-origin requests without validation is readily exploitable and should be avoided.”
Without cookies, reflection gives a stranger the same as *: in our lab, Chrome blocked the reflecting route as soon as the stranger’s page asked with cookies, because there was no credentials header. With Access-Control-Allow-Credentials: true added, it’s check 5.
Our scan reports a made-up origin echoed back without credentials as a medium finding: “CORS reflects a foreign origin” on the homepage, or “An API route reflects any origin” on an API route. A route that turns the made-up origin away but lets in a lookalike of your address or null gets “accepts lookalike origins” or “accepts the null origin”. Check 6 explains both.
05
Cookies plus an open origin: the one that leaks accounts
Credentials mostly means cookies. When your API answers with the asking site’s origin and Access-Control-Allow-Credentials: true, the browser sends the user’s cookies along and lets that site read the answer. In MDN’s words, if the request carries a cookie and the response names “an actual origin rather than the wildcard,” then “the browser will allow access to the response from the specified origin.” If your API names every origin, every site gets that.
Here’s what our stranger’s page could read once we had signed in to the API in the same browser:
What the stranger's page could read, after we signed in to the API:
/wild cors() no cookies: {"signedInAs":null}
/wild cors() with cookies: blocked
/wild-cred * plus Allow-Credentials: true with cookies: blocked
/reflect cors({ origin: true }) with cookies: blocked
/reflect-cred cors({ origin: true, credentials }) with cookies: {"signedInAs":"alice@example.com"}
/allow cors({ origin: [our app], credentials }) with cookies: blocked
/null-allowed our app and "null" allowed, called from a sandboxed iframe:
{"signedInAs":"alice@example.com"}Two routes leaked our test user’s data to a site that had nothing to do with the app. One reflected every origin with credentials. The other only allowed our app and the value null, and the stranger got around that by calling from a sandboxed iframe, which sends Origin: null. MDN’s reference warns about exactly this: “The value null should not be used,” because “any origin can create a hostile document with a null origin.” OWASP’s 2025 Top 10 lists CORS misconfiguration under broken access control, its number one risk, for this reason.
Look at which cookie made it across: only sid, the one we set with SameSite=None. The Lax cookie and the one with no SameSite at all stayed home. MDN’s Set-Cookie page explains that Lax cookies aren’t sent with fetch() from other sites, and that “Some browsers use Lax as the default value if SameSite is not specified.” So the leak needs a SameSite=None cookie. That’s the cookie you end up with when your front end and API are on different sites and sign-in only works after you loosen it, which is exactly when people loosen CORS too. Some browsers block third-party cookies on top of that, MDN notes, but Chrome sent ours, so don’t count on it.
And * with Access-Control-Allow-Credentials: true? Browsers refuse that pair, and Chrome blocked it in our test, so it doesn’t leak today. Our scan still rates it high, because the server is set up to trust every site, and the obvious next step is to reflect the origin to make the error go away. Fix it the same way.
06
Allowlists that let in more than you meant
The right fix is a list of the sites you trust. The common mistake is checking that list loosely. PortSwigger’s example: an app that allows every origin ending in normal-website.com also lets in someone who registers hackersnormal-website.com. The cors package’s own docs show the pattern /example\.com$/ as the way to allow origins ending in example.com. We tried the same shape:
// The kind of "allow my domain" that lets in more than your domain
app.use(cors({ origin: /yourapp\.com$/, credentials: true }))
// curl -H "Origin: https://notyourapp.com" ... answered:
// Access-Control-Allow-Origin: https://notyourapp.com
// Access-Control-Allow-Credentials: trueThe rules that avoid all of this:
- Compare exact strings. Keep the list as full origins, like
https://yourapp.com, with no path and no trailing slash, and check membership with a Set or an array of strings. NoendsWith,startsWith,includesor regex. - Never allow
null. Not even “just for local testing.” Check 5 showed why. - Never allow a whole hosting domain. A rule like “anything on
.vercel.app” to cover preview deployments also covers every other Vercel user’s app.vercel.app,netlify.app,lovable.app,replit.appandbolt.hostare all on the Public Suffix List, meaning strangers get their own sites under them. Vercel’s guide suggests driving the list from an environment variable for previews instead. - Keep
localhostout of the production list. Add it only when you’re running locally. - Send
Vary: Originwhen you echo an allowed origin. MDN says the response “should also include a Vary response header with the value Origin”. Vercel’s guide explains that without it, a CDN can serve the answer approved for one origin to a request from another, and the browser then blocks it. It isn’t a leak, but it’s a confusing bug.
07
Fix it with one exact list, where your code runs
Before writing any code, answer one question per API: who really needs to read it from a browser?
- Only your own pages, on the same address. Remove the CORS headers and the package. That’s the safest setup there is.
- Anyone, and it’s public data. Keep
*on those routes only, with no credentials header. - Your front end on another address. One exact list, kept in one place, used everywhere. Add
Access-Control-Allow-Credentials: trueonly if that front end sends cookies. MDN says that if you don’t need credentials, “omit this header entirely rather than setting its value to false.”
Next.js: route handlers and proxy
Put the list in one file:
// lib/cors.ts: the only sites allowed to read your API from a browser.
// Exact strings: scheme + host (+ port), no trailing slash, no wildcards.
const ALLOWED_ORIGINS = new Set([
"https://yourapp.com",
"https://www.yourapp.com",
// "http://localhost:3000", // only while developing
]);
export function corsHeaders(origin: string | null): Record<string, string> {
const headers: Record<string, string> = { Vary: "Origin" };
if (origin && ALLOWED_ORIGINS.has(origin)) {
headers["Access-Control-Allow-Origin"] = origin;
// Only if your front end sends cookies to this API from another site:
headers["Access-Control-Allow-Credentials"] = "true";
}
return headers;
}Use it in a route handler, including the OPTIONS answer for preflights:
// app/api/me/route.ts
import { corsHeaders } from "@/lib/cors";
export async function OPTIONS(request: Request) {
return new Response(null, {
status: 204,
headers: {
...corsHeaders(request.headers.get("origin")),
"Access-Control-Allow-Methods": "GET, POST",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
"Access-Control-Max-Age": "600",
},
});
}
export async function GET(request: Request) {
// Check who is asking first, exactly as you would without CORS.
const data = { ok: true };
return Response.json(data, { headers: corsHeaders(request.headers.get("origin")) });
}Or set it once for every API route in proxy.ts. Next.js 16 renamed middleware.ts to proxy.ts. On Next.js 15, name the file middleware.ts and the function middleware, and the rest is the same. This is close to Next.js’s own proxy example, with Vary: Origin added:
// proxy.ts (middleware.ts before Next.js 16): one allowlist for every /api route
import { NextResponse, type NextRequest } from "next/server";
import { corsHeaders } from "@/lib/cors";
export function proxy(request: NextRequest) {
const cors = corsHeaders(request.headers.get("origin"));
if (request.method === "OPTIONS") {
return new NextResponse(null, {
status: 204,
headers: {
...cors,
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE",
"Access-Control-Allow-Headers": "Content-Type, Authorization",
"Access-Control-Max-Age": "600",
},
});
}
const response = NextResponse.next();
for (const [key, value] of Object.entries(cors)) response.headers.set(key, value);
return response;
}
export const config = { matcher: "/api/:path*" };Our check 2 loop against the production build, with one extra line for the real origin:
== Origin: https://evil.example
== Origin: null
== Origin: https://yourapp.com.evil.example
== Origin: https://notyourapp.com
== Origin: https://yourapp.com
access-control-allow-credentials: true
access-control-allow-origin: https://yourapp.comThe preflight from https://evil.example still got a 204, but with no allow-origin line, so the browser stops there. Server Actions and Server Components don’t need any of this. They run on your server and the browser treats them as same-origin.
Supabase Edge Functions
Supabase’s CORS docs use *, through the corsHeaders you can import from @supabase/supabase-js/cors or the withSupabase wrapper that adds them for you. For most functions your app calls with supabase.functions.invoke() that’s honestly fine. The Supabase client sends the signed-in user’s token in the Authorization header, not in a cookie, and a stranger’s page doesn’t have that token. What protects the function is checking that token, which our anon key guide walks through. A locked-down origin doesn’t stop anyone with curl.
If you’d still rather only your own site’s pages could call a function from a browser, set the origin in the wrapper:
// supabase/functions/my-function/index.ts, one site allowed
import { withSupabase } from "npm:@supabase/server@^1";
import { corsHeaders } from "npm:@supabase/supabase-js@^2/cors";
export default {
fetch: withSupabase(
{
auth: "user",
// Spread the defaults first: the object you pass replaces them.
cors: { headers: { ...corsHeaders, "Access-Control-Allow-Origin": "https://yourapp.com" } },
},
async (req, ctx) => Response.json({ ok: true }),
),
};Spread the defaults first. In @supabase/server 1.9.2 the headers you pass replace Supabase’s list instead of adding to it, and without Access-Control-Allow-Headers the browser’s preflight fails for every call the client makes. A single fixed origin doesn’t need Vary, because the answer is the same for everyone. For more than one origin, check the list yourself:
// More than one site, without withSupabase
import { corsHeaders } from "npm:@supabase/supabase-js@^2/cors";
const ALLOWED_ORIGINS = new Set(["https://yourapp.com", "https://www.yourapp.com"]);
function cors(req: Request): Record<string, string> {
const origin = req.headers.get("origin");
const headers: Record<string, string> = { ...corsHeaders, Vary: "Origin" };
delete headers["Access-Control-Allow-Origin"];
if (origin && ALLOWED_ORIGINS.has(origin)) headers["Access-Control-Allow-Origin"] = origin;
return headers;
}
Deno.serve(async (req) => {
if (req.method === "OPTIONS") return new Response(null, { status: 204, headers: cors(req) });
// ...check the caller's token here, then:
return Response.json({ ok: true }, { headers: cors(req) });
});Express (Replit and other Node servers)
Give the cors package an array of exact strings. Leave out credentials unless your front end is on another site and sends cookies:
import cors from "cors";
// Before: app.use(cors()) or app.use(cors({ origin: true, credentials: true }))
app.use(
cors({
origin: ["https://yourapp.com", "https://www.yourapp.com"],
credentials: true, // leave this out unless cookies cross sites
}),
);== Origin: https://evil.example
Vary: Origin
Access-Control-Allow-Credentials: true
== Origin: https://yourapp.com
Access-Control-Allow-Origin: https://yourapp.com
Vary: Origin
Access-Control-Allow-Credentials: trueThe package adds Vary: Origin for you, and the lone credentials line that strangers get is harmless. If your Express server also serves your pages, as it usually does on Replit, you probably don’t need the package at all. Our Replit guide covers the rest of an Express server’s headers and cookies.
Vercel and Netlify config files
Both hosts let you set headers without code, and both only do fixed values. On Vercel, vercel.json applies them at the CDN before your function runs. Vercel’s CORS guide notes that this layer “supports only static values, so it can’t validate an origin against an allowlist.” That’s fine for one front end:
{
"headers": [
{
"source": "/api/(.*)",
"headers": [
{ "key": "Access-Control-Allow-Origin", "value": "https://yourapp.com" },
{ "key": "Access-Control-Allow-Methods", "value": "GET, POST, OPTIONS" },
{ "key": "Access-Control-Allow-Headers", "value": "Content-Type, Authorization" }
]
}
]
}Vercel’s own first example also adds Access-Control-Allow-Credentials: true. Only copy that line if you need cookies across sites. If your preflights get a 401 on a preview deployment, that’s Deployment Protection answering before your code runs. The same guide shows the OPTIONS allowlist that fixes it. Never put a dynamic “echo the origin” rule in here.
On Netlify, the _headers file and [[headers]] in netlify.toml only cover static files. Netlify’s headers docs say they aren’t applied to anything a function or edge function handles: “the site being proxied to or the function should return any required headers instead.” So a Netlify Function sets its own CORS headers in code, the same way as the Express or Supabase examples above. A * in _headers for /* only touches your public files, which is usually harmless.
If you’d rather have your AI builder do the change, this is the prompt we’d use. Put your real domains in it:
Find every place this project sets CORS: the cors package, Access-Control-Allow-Origin headers in route handlers, middleware or proxy files, next.config, vercel.json, netlify.toml, _headers files and Supabase Edge Functions. On any route that returns data about a signed-in user, replace "*", origin: true, and any code that copies the request's Origin header back, with one exact list of allowed origins kept in one file: https://yourapp.com and https://www.yourapp.com. Compare origins as exact strings. Never use endsWith, startsWith, includes or an unanchored regex, and never allow "null". Add Vary: Origin wherever the allowed origin is echoed. Only send Access-Control-Allow-Credentials: true if the front end really sends cookies to this API from another site. If the front end and the API are on the same domain, remove the CORS headers instead. Don't change anything else, and list every file you changed.08
Test again, and keep it from coming back
Run check 2 again on every API. You want nothing printed for the four strangers, and your own origin, if you add it to the loop, echoed back. Then open your live app, sign in, and click through every screen with DevTools open on the Console and Network tabs. Locking CORS down is the kind of change that breaks one screen you forgot about.
If something breaks, the error usually says why:
- “No ‘Access-Control-Allow-Origin’ header is present.” The page’s origin isn’t on your list. Compare it character by character: www or not, http or https, a port, a trailing slash.
- “must not be the wildcard ‘*’ when the request’s credentials mode is ‘include’.” That route still answers
*while your front end sends cookies. Name the origin from your list. - The preflight fails. The OPTIONS request got no CORS headers, a
401or a404. Answer OPTIONS like the examples above, and on Vercel check Deployment Protection.
The way this comes back is the next CORS error. A new route, a new preview domain or a new front end, and the quickest suggestion is * or origin: true again. When that happens, ask for the narrow fix:
This CORS error appears when my app at https://yourapp.com calls the API. Add exactly that origin to the existing CORS allowlist. Don't use "*", don't copy the request's Origin header back, and don't add origin: true.What a clean result means
Your API either sends no CORS headers because nothing needs them, sends * only on public data with no credentials line, or names one origin from an exact list that has no null, no lookalikes and no shared hosting domains. Cookies cross sites only where you meant them to. If that’s you, a page on some other site can’t read your users’ data out of their browsers. That still says nothing about who can call your API directly, so keep the login and ownership checks from our API route authentication guide on every route.
Where LockShip fits
We built LockShip to read your app from the outside, the way a stranger would. For CORS, here’s exactly what that covers. The scan loads your homepage once with a made-up origin, https://lockship-probe.invalid, and reads two headers. Then it asks up to four API routes the same question a stranger’s page would. It takes the /api paths your own JavaScript calls first, then a few common names like /api/me and /api/health, and for each one sends a GET with the made-up origin. If that’s turned away, it tries two lookalikes of your address (yourapp.com.lockship-probe.invalid and lockship-probe-yourapp.com) and Origin: null. Last, one OPTIONS preflight asks whether a POST with a JSON body would be allowed. It sends no cookies or keys, reads only the two CORS headers, and stops after 24 requests.
If any answer comes back with Access-Control-Allow-Credentials: true, that’s high, linked to check 5. On the homepage it’s “CORS allows any origin with credentials” or “CORS reflects an arbitrary origin with credentials,” and on an API route it says which door was open: “reflects any origin”, “trusts lookalike origins”, “trusts the null origin” or “allows any origin”, each with credentials. Without credentials, * is the low “CORS allows any origin” finding, or “An API route allows any origin”, linked to check 3. An echoed made-up, lookalike or null origin is medium too, linked to check 4. When an API route says exactly what the homepage said, the report adds the route to the homepage finding instead of listing it twice.
What it doesn’t do: it only asks routes it can find in your JavaScript or guess, never Supabase Edge Functions or other APIs on another address, and it doesn’t sign in, so it can’t tell whether your cookies are SameSite=None. Checks 2 and 6 are yours. Apart from those preflights, the scan only sends GET and HEAD requests, and it never writes anything. A clean result means “nothing obvious from the outside right now,” not “safe.”
The summary is free: a score and the single worst thing we found. The $39 Launch Safe certificate includes every finding with a fix prompt you can paste into your builder, a PDF, and seven days of re-scans while you fix things. Monitor, at $9 a month, re-runs the scan every week and emails you once when a new critical or high issue shows up, like an API route that starts reflecting origins with credentials after a deploy.
Want to see what your app tells a stranger’s site?
Paste your app’s address, prove you own it, and see the worst thing we find. The summary is free.
Run a free scanBefore you rely on a result, read the disclaimer.
Questions people ask
Is Access-Control-Allow-Origin: * a security hole?
Not on its own. Browsers won’t send cookies with a request and then let another site read the answer when the answer is *, so a stranger’s page only gets what a signed-out visitor could see anyway. It’s fine for public data. It becomes a problem when it’s a blanket rule that also covers routes returning private data some other way, or when someone later swaps it for an echoed origin to make cookies work.
Why do I still get a CORS error after adding the header?
The usual reasons: the request sends cookies and the answer is *, which browsers refuse; the browser’s preflight OPTIONS request gets no CORS headers or an error, so the real request never runs; the origin on your list doesn’t match exactly (www or not, http or https, a trailing slash); on Vercel, Deployment Protection answers the preflight with 401 before your code runs; and on Netlify, headers from _headers or netlify.toml don’t apply to functions, so the function has to send them itself.
Does CORS stop other people from calling my API?
No. CORS only tells browsers which other sites’ JavaScript may read the answer. Your server still receives and runs every request, and curl, scripts and other servers ignore CORS completely. Every route still has to check who is asking.
Do I need CORS at all if my front end and API are on the same domain?
No. A page calling its own origin isn’t a cross-origin request, so the browser doesn’t need any CORS header. That’s most Next.js, v0 and Replit apps. If you find app.use(cors()) or Access-Control-Allow-Origin headers in an app like that, you can usually delete them.
Does a strict CORS setup protect me from CSRF?
No. A plain form or a simple POST from another site is still sent, with whatever cookies the browser decides to attach. CORS only hides the answer. Protect actions that change things with SameSite cookies, CSRF tokens or a check of the Origin header on the server.
More on CSRF: OWASP’s CSRF prevention cheat sheet covers tokens, SameSite cookies and checking the Origin header, and why a custom request header only helps when your CORS list is strict.
Keep reading
- Vibe coding security checklist: what to check before you launch an AI-built app
- Security headers for vibe-coded apps: CSP, HSTS and the rest, with configs we tested
- Supabase anon key exposed? What a stranger can see and call with it
- Is my v0 app secure? A plain check before you launch
- Is my Replit app secure? A plain check before you launch
- Is my Cursor app secure? A plain check before you launch
- HTTPS for vibe-coded apps: redirects, HSTS, mixed content and certificates that won’t issue
Sources
We read each of these on 25 October 2026. Frameworks and hosts change their examples, so if something here disagrees with their docs, trust the docs and tell us at hi@lockship.dev. The browser results are our own, from headless Chrome 155 against a test API and a stranger’s page on our own machine, with a fake user. We didn’t test on any host’s account, and we didn’t run any of this against anyone else’s app.
- Cross-Origin Resource Sharing (CORS), MDN
- Same-origin policy, MDN
- Origin header, MDN
- Access-Control-Allow-Origin, MDN
- Access-Control-Allow-Credentials, MDN
- Set-Cookie (SameSite), MDN
- Cross-origin resource sharing (CORS), PortSwigger Web Security Academy
- A01:2025 Broken Access Control, OWASP Top 10
- HTML5 Security Cheat Sheet (Cross Origin Resource Sharing), OWASP
- Cross-Site Request Forgery Prevention Cheat Sheet, OWASP
- cors (configuration options and common misconceptions), Express on GitHub
- route.js (CORS), Next.js docs
- proxy.js (CORS), Next.js docs
- headers in next.config.js (CORS), Next.js docs
- CORS support for invoking from the browser, Supabase docs
- CORS on Vercel, Vercel Knowledge Base
- Custom headers, Netlify docs
- Public Suffix List, publicsuffix.org