Is my CORS configuration safe, and how do I check it?
It is safe when your API names the exact origins that may read its responses, and never answers with * or echoes back any origin on requests that carry cookies or other credentials. You can check it with one request: send a made-up Origin header and read the Access-Control-Allow-Origin header that comes back. CORS is applied by browsers, so it never replaces sign-in and access checks.
Saqr (usesaqr.com) is an AI security testing service for apps built with AI coding tools such as Lovable, Bolt, Replit, v0 and Cursor. From $19 a month, cancel any time. Tests only apps you have shown are yours.
By Saqr. Last checked .
What does CORS actually control?
Browsers restrict cross-origin requests made by scripts. CORS is how a server tells the browser which other origins (a scheme, domain and port) may read its responses. The browser sends an Origin header with every such request, and for methods that can change data it first sends a "preflight" OPTIONS request to ask permission (MDN).
Two consequences matter. CORS is a browser rule, so your API must still check who is calling on every request. And OWASP notes that CORS does not stop data going somewhere it should not, and that the usual protection against cross-site request forgery is still needed (OWASP cheat sheet).
Which CORS answers are risky?
| What the API answers | Verdict |
|---|---|
No Access-Control-Allow-Origin header | Only your own origin can read responses in a browser |
Your own origin, with Vary: Origin | The setup MDN describes for a list of allowed origins |
* on public data with no credentials | Fine, if nothing in the response is private |
* with credentials | Browsers refuse it (MDN) |
Any origin echoed back, with Access-Control-Allow-Credentials: true | Risky: any site a signed-in user visits could read their data |
null | Should be avoided, because any origin can create a document whose origin is null (MDN) |
OWASP's advice: allow only selected, trusted domains, and do not use * or blindly return the Origin header without checks (OWASP cheat sheet). Its Top 10 lists CORS misconfiguration under broken access control (OWASP Top 10, A01).
How do I check my CORS settings?
Six checks from a terminal and the developer tools. Replace the example addresses with your own. Do these checks only on an app you own or have written permission to test, with test accounts you created.
Find your API's addresses
Use your app with the Network tab open and note the requests that go to your API. If the API is on the same origin as your pages, CORS may not be involved at all; if it is on another subdomain or domain, it is.
Send a request with a made-up origin
Run
curl -s -o /dev/null -D - -H "Origin: https://example.org" https://api.yourcompany.com/your-endpointand readAccess-Control-Allow-OriginandAccess-Control-Allow-Credentialsin the output. A safe answer leaves them out or names only your own origin. Ifhttps://example.orgcomes back, the API echoes any origin.If it fails: Restrict CORS to the origins your app uses
Try null and look-alike origins
Repeat with
Origin: null, withhttps://yourcompany.com.example.organd withhttps://notyourcompany.com. A check that only looks for your domain somewhere in the origin lets look-alikes through. None of them should be echoed back.If it fails: Restrict CORS to the origins your app uses
Send the preflight
Run the same command with
-X OPTIONSand-H "Access-Control-Request-Method: DELETE". ReadAccess-Control-Allow-MethodsandAccess-Control-Allow-Headers: they should list only what your app uses, and only for your origin.Search your code for permissive defaults
Search the code for
Access-Control-Allow-Originandcors(and read each one. Examples often start from*; even the Next.js documentation's example sets*with a note to set your own origin (Next.js headers).If it fails: Restrict CORS to the origins your app uses
Confirm sign-in still protects the data
Request a private endpoint from the terminal without any cookie or token. It should answer 401, whatever the CORS headers say, because a request from outside a browser does not go through CORS.
If it fails: Require sign-in on every API route by default
How do I fix a loose CORS setting?
Keep a list of exact origins (scheme, host and port). Compare each request's Origin with the list, and only when it matches, answer with that origin and Vary: Origin (MDN). Send Access-Control-Allow-Credentials: true only if the browser really must send cookies; if you do not need credentials, MDN says to leave the header out entirely (MDN). Then repeat the made-up origin check.
Facts worth knowing, with sources
- Browsers refuse Access-Control-Allow-Origin: * on requests that carry credentials. Source
- MDN says the null value for Access-Control-Allow-Origin should be avoided. Source
- OWASP advises allowing only selected, trusted domains and never blindly returning the Origin header. Source
- OWASP lists CORS misconfiguration as an example of broken access control, the first category of its Top 10 for 2025. Source
Questions
Is Access-Control-Allow-Origin: * always bad?
No. For public data that needs no sign-in, such as a public read-only API, it is fine. It becomes a problem when responses hold private data, and browsers refuse * on requests that carry credentials anyway.
Does CORS protect my API from other servers?
No. CORS is applied by browsers. A request from a server or a terminal does not go through it, so your API must check sign-in and permissions on every request.
Why does a request work in a terminal but fail in the browser?
Because the browser applies CORS and the terminal does not. The browser's console names the reason; MDN notes that the details of a CORS failure are not available to the page's JavaScript.
Where does Saqr fit?
These checks cover what is on the list, on the pages you think to try. Saqr runs this kind of test on the live app for you, in a real browser and including signed-in pages, and shows the proof for each finding with a fix prompt for your AI coding tool. After you fix something, ask it to recheck. Plans are Starter at $19 a month and Pro at $49 a month, and you can cancel any time.
Every task ends in three PDFs. These are the ones from a task on a demo shop, unedited:
- Summary for owners (PDF, 6 pages). What was found and what to fix first.
- Technical report for developers (PDF, 29 pages). Every finding, with its proof and the steps to fix it.
- AI fix pack (PDF, 10 pages). A ready-to-paste fix prompt for every finding.
No test can promise an app is secure. A task tells you what Saqr found that day, with proof.
Which other guides should I read?
- Is my Lovable app secure?
- Is my Bolt app secure?
- Is my Replit app secure?
- Is my v0 app secure?
- Is my Cursor-built app secure?
- Is my Supabase app secure?
- Is my Firebase app secure?
- How do I check if my vibe-coded app is secure?
- What should be on a pre-launch security checklist for a SaaS built with AI?
- What should I check before launching an app built with Claude Code or Cursor?
- What is the OWASP Top 10, in plain words?
- How do I test my own app for broken access control (IDOR)?
- How do I test Supabase row level security?
- Supabase anon key vs service_role key: which one is safe in the browser?
- How do I check if a Supabase storage bucket is public?
- How do I check my Firebase security rules?
- My Firebase API key is public. Is that safe?
- I exposed an API key in my frontend. What do I do now?
- How do I add and test login rate limiting in an app built with AI tools?
- Are my session cookies secure, and how do I check them?
- Which security headers should my Next.js or Vite app set?
- Security fix prompts for your AI coding tool
- Saqr, automated scanners and a manual penetration test
- Questions about securing an app built with AI tools
To see what a finished test looks like, open the sample reports.
Sources
The statements above were checked against these pages on 24 November 2026. Products change; follow the links for the current wording.
- MDN: Cross-Origin Resource Sharing (CORS)
- MDN: Access-Control-Allow-Origin
- MDN: Access-Control-Allow-Credentials
- OWASP cheat sheet: HTML5 Security
- OWASP Top 10:2025, A01 Broken Access Control
- Next.js documentation: headers
Saqr is independent and is not affiliated with Next.js. Each name is a trademark of its owner.