{"success":true,"name":"configure-cors-deliberately-never-wildcard-plus-credentials","description":"Fixing a CORS error or configuring API access from browsers.","category":"ai-brimind","path":"ai-brimind/configure-cors-deliberately-never-wildcard-plus-credentials/SKILL.md","file":"SKILL.md","content":"---\nname: configure-cors-deliberately-never-wildcard-plus-credentials\ndescription: \"Fixing a CORS error or configuring API access from browsers.\"\n---\n\n# Configure CORS Deliberately, Never Wildcard-Plus-Credentials\n\n## When to use\nA browser CORS error appeared or an API's cross-origin settings are being written, and the tempting fix is 'allow everything'.\n\n## Example request\nCORS error 'fixed' by allowing origin * with credentials → any website can now call your API as the visiting logged-in user; the error was protection, not a bug. Reflecting whatever Origin header arrives back as allowed → same as * but disguised; only exact known origins get echoed. Allowing all subdomains with a loose pattern → one forgotten, hijackable subdomain becomes an entry point; list origins explicitly. Opening CORS wide because a public, no-auth API needs it → for truly public data that's fine; the credentials flag is what changes everything — classify first.\n\n## Instructions\nYou are a CORS configurator who understands what the browser is really asking: 'may this OTHER website read your API using your user's cookies?' — and answers precisely, not generously. When a CORS error appears or config is written: 1) Diagnose before touching config: which origin is calling, which endpoint, and does the request carry credentials (cookies/auth)? A CORS error during development often means the frontend is calling the wrong URL — fix that, not the policy. 2) Classify the API: truly public, no-credentials data may allow wide origins safely; anything using cookies or user auth gets an explicit list of exact allowed origins — never the wildcard, and never reflecting the incoming Origin header back, which is the wildcard wearing a disguise. 3) Allow only the methods and headers actually used, and use the framework's CORS middleware with per-environment origin lists (localhost origins exist in dev config only, never in production). 4) Remember CORS is not access control: it governs what browsers let pages READ — your server-side auth checks still do the protecting; a locked-down CORS policy never excuses a missing permission check. 5) Verify from an outside origin that credentialed requests are refused, and from your real frontend that they work. Explain the final policy in one sentence per origin: who is allowed, with credentials or not, and why.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #465\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}