Works with the AI Agents you already use
Fix CORS Errors and Set HTTP Security Headers
Find the real cause of a CORS error, fix it in the right layer, and audit CSP, HSTS and other security headers. Verdict SECURE / NEEDS FIXES / EXPOSED.
$5
Fix CORS Errors and Set HTTP Security Headers
Example session with this skill installed
My React app on https://app.example.com calls our Express API on https://api.example.com with fetch credentials: 'include'. I got "Credential is not supported if the CORS header 'Access-Control-Allow-Origin' is '*'", so I changed cors() to origin: true and now it works. Is this fine?
- Read your context and instructions
- Compiled the fix cors errors
Verdict: EXPOSED
The API reflects any Origin with credentials enabled, so any website can read logged-in users' responses.
Root cause
Your fetch uses credentials: 'include'. The first deploy sent Access-Control-Allow-Origin: *, which browsers reject with credentials. The "fix" origin: true echoes every Origin, so the error is gone but the hole is open.
Evidence (preflight from a disallowed origin):
HTTP/1.1 204 No Content
Access-Control-Allow-Origin: https://evil.example
Access-Control-Allow-Credentials: true
Pass/fail
| Check | Current | Expected | Result |
|---|---|---|---|
| Allowlist | reflects any origin | 2 listed origins | FAIL |
| Credentials + wildcard | reflected | explicit origin | FAIL |
| Preflight status | 204 | 204/200, no redirect | PASS |
| Vary: Origin | present | present | PASS |
| Allow-Headers | reflected | Content-Type, Authorization | WARN |
| CORS on 401/500 | missing | present | FAIL |
Fix - Express (cors)
- app.use(cors({ origin: true, credentials: true }));
+ const allow = ['https://app.example.com', 'https://admin.example.com'];
+ app.use(cors({
+ origin: allow,
+ credentials: true,
+ methods: ['GET', 'POST', 'PUT', 'DELETE'],
+ allowedHeaders: ['Content-Type', 'Authorization'],
+ maxAge: 600,
+ }));
Move app.use(cors(...)) above app.use(requireAuth) so 401 responses also carry CORS headers.
Verify
curl -sS -o /dev/null -D - -X OPTIONS https://api.example.com/v1/items \
-H "Origin: https://app.example.com" \
-H "Access-Control-Request-Method: PUT" \
-H "Access-Control-Request-Headers: content-type"
# expect: Access-Control-Allow-Origin: https://app.example.com
# Access-Control-Allow-Credentials: true
# Vary: Origin
curl -sS -o /dev/null -D - -X OPTIONS https://api.example.com/v1/items \
-H "Origin: https://evil.example" -H "Access-Control-Request-Method: PUT"
# expect: no Access-Control-Allow-Origin line
Not checked
Security headers (run headers mode next), CDN caching of API responses.
Connects securely to your tools. The creator never sees your data.
About this skill
CORS errors are hard to read. The browser message often hides the real problem: a preflight that hits auth middleware, a redirect on OPTIONS, two layers both adding headers, or an error response with no CORS headers at all. The quick fix people reach for, echoing any Origin with credentials, makes the error go away and opens a real security hole. Security headers have the same problem: copy-pasted configs with deprecated headers, a CSP that breaks the site on day one, or HSTS preload added without knowing it is hard to undo.
This skill gives your coding agent a fixed procedure for both jobs.
- Classifies the browser error against a decision table of common real causes
- Reproduces it with curl preflight and actual requests, for allowed and disallowed origins
- Finds which layer owns CORS (app, Nginx, CDN, host, API gateway) and fixes it in one place
- Uses an explicit origin allowlist; never a wildcard or reflected origin with credentials
- Snippets for Express, Fastify, Next.js proxy and route handlers, Django, FastAPI, Spring, ASP.NET Core, Nginx, Vercel, Netlify, Cloudflare and AWS API Gateway
- Audits CSP, HSTS, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, COOP, COEP, CORP and cookie flags, and flags deprecated headers for removal
- Gives a CSP rollout plan that starts in Report-Only mode
- Returns a pass/fail table, a config diff, verification commands and a SECURE / NEEDS FIXES / EXPOSED verdict
For web and API developers, DevOps engineers and anyone preparing for a security review.
Honesty note: the reference file was checked against MDN, the OWASP Secure Headers Project, hstspreload.org and framework docs as of October 2026, and it lists which snippets were not re-checked. The skill tells the agent to confirm framework versions and docs rather than guess.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for Security.
The skill relies on curl for live checks and cannot inspect layers or headers it cannot reach. It does not replace a penetration test or API authentication; CORS only controls what browsers let pages read. Framework syntax changes between major versions, so the agent should confirm your installed version. Browser behavior notes reflect documentation as of October 2026.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 29 days ago
- Software
- curl@next/codemod
Node.js
curl reproduces and verifies CORS preflights and response headers.
Permissions
Allowed Hosts