API Cors

Configure CORS for browser-facing APIs: simple vs preflight, Allow-* headers, credentials, and origin allowlists. Use when enabling SPA access or debugging OPTIONS preflight failures.

deangrant b0014b5 4 files · 2.0 KB Updated

File contents

Cross-Origin Resource Sharing (CORS)

Use this skill when browsers call the API from another origin.


1. Simple vs preflight

Simple requests skip preflight; others trigger OPTIONS with Access-Control-Request-*. Respond with Access-Control-Allow-Origin, Allow-Methods, Allow-Headers, and optional Max-Age.


2. Credentials

With cookies/credentials: explicit origins — never * with credentials. Reflect only allowlisted origins.


3. Quick checklist

  • Explicit origin allowlist (no * with credentials).
  • OPTIONS preflight handled.
  • Methods/headers allowlists match real API.
  • Do not use CORS as an authz control (server still enforces auth).

See reference.md and examples.md.

deangrant/agents/tree/main/.agents/skills/api-cors commit b0014b5139

Frequently asked questions

npx skillmds@latest add deangrant/api-cors