Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseDotsDots+21 more

    Fix CORS Errors and Set HTTP Security Headers

    1

    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

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Fix CORS Errors and Set HTTP Security Headers

    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

    CheckCurrentExpectedResult
    Allowlistreflects any origin2 listed originsFAIL
    Credentials + wildcardreflectedexplicit originFAIL
    Preflight status204204/200, no redirectPASS
    Vary: OriginpresentpresentPASS
    Allow-HeadersreflectedContent-Type, AuthorizationWARN
    CORS on 401/500missingpresentFAIL

    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.

    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. 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. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before any payment.

    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

    Requires

    curl
    @next/codemod
    Node.js

    Permissions

    Terminal / Shell
    Network Access

    Allowed Hosts

    api.example.com
    app.example.com
    example.com
    Listed29 days ago

    What's inside

    Frequently Asked Questions

    A SKILL.md file with the CORS and headers procedures, verdict rules, output template and checklist, plus references/cors-headers-reference.md with the error decision table, stack snippets, the header baseline, CSP and HSTS preload notes, and the source list.

    Any agent that loads SKILL.md skills, such as Claude Code, Codex CLI, Cursor, VS Code Copilot and Gemini CLI.

    Unzip the folder into your agent's skills directory (for Claude Code, ~/.claude/skills/ or .claude/skills/ in a project), then ask about a CORS error or a header audit.

    It needs network access to curl a live URL; without it, it works from your config files and says so. It cannot see headers added by layers you do not share. Some framework snippets are from documentation knowledge and are marked to check against current docs.

    A plain prompt often suggests reflecting the Origin or using a wildcard to make the error disappear. This skill makes the agent reproduce the problem with curl first, fix it in one layer with an explicit allowlist, test a disallowed origin, and stage CSP in Report-Only mode before enforcing.

    You simply need to provide the error message from your browser console or the current response headers, along with a mention of your tech stack (e.g., 'I am using Nginx and Node.js').

    New in Security