🇪🇸 Cambiar a versión en español: Generador y Auditor de Headers CORS Privado
Generate and audit production HTTP CORS (Cross-Origin Resource Sharing) headers for Nginx, Express.js, and Cloudflare Workers 100% locally in your browser. Automatically catch browser-breaking traps like pairing Access-Control-Allow-Origin: * with Allow-Credentials: true or omitting Vary: Origin on CDN caches.
WHATWG Fetch CORS Spec Traps (Why APIs Break in Browsers)
| Header Combination | Browser Behavior | Production Root Cause |
|---|---|---|
Origin: * + Credentials: true | Hard Browser Rejection | Prohibited by Fetch spec; must echo a strictly allowlisted exact origin |
Dynamic Origin without Vary: Origin | CDN Cache Poisoning | Shared caches serve Origin A's CORS headers to Origin B users |
Content-Type: application/json | Forces OPTIONS Preflight | Only text/plain, form-urlencoded, and multipart stay "simple" |
Max-Age: 86400 (24h) | Trims Preflight Roundtrips | Chromium caps cache internally at 2 hours (7200s); Firefox allows 24 hours |
CORS Validation & Preflight Decision Logic
•
Simple Request = Method in {GET, HEAD, POST} AND safe CORS headers AND Content-Type in safelist.•
Credentialed Requests = Allow-Credentials: true strictly forbids wildcard * in Origin, Methods, or Headers.• Whenever matching multiple origins dynamically, always append
Vary: Origin before CDN edge caching.
HTTP CORS & Preflight FAQ
Why does my API work in Postman or curl yet fail in Chrome with a CORS error?
CORS is strictly enforced by web browsers under the Same-Origin Policy, never by server-to-server HTTP clients. If an OPTIONS preflight returns 401 or omits Access-Control-Allow-Origin before auth middleware runs, browsers reject the request.
Why is blindly reflecting the incoming Origin header dangerous?
Echoing unvalidated Origin headers alongside Allow-Credentials: true effectively turns off Same-Origin protection, letting malicious third-party tabs read authenticated API responses.
Canonical Specifications: MDN CORS Guide · WHATWG Fetch Living Standard · Cross-Origin Resource Sharing Overview.
100% offline browser execution: zero API origins or config snippets ever leave your machine.