When to use this generator
- A browser calls your API from another origin (different scheme, host, or port) and the console shows a CORS or preflight failure.
- You are writing infra-as-code, nginx, API Gateway, or Lambda config and need the exact header lines to paste.
- You want to compare a strict setup (named origins, no credentials) vs a dev-only relaxed setup before you lock production.
Real-world example
A React app at https://app.example.com posts JSON with Authorization to https://api.example.com. You allow that origin (not *), include OPTIONS, list Content-Type and Authorization in allow-headers, and set Allow-Credentials: true because you use cookies—this tool outputs the matching header block for you to wire into the server.
Common mistakes
*with credentials: browsers reject it; list explicit origins.- Missing custom headers (e.g.
X-Request-Id) in allow-headers—preflight fails even when GET works. - Forgetting OPTIONS on the server route so preflight never returns 204/200 with these headers.
Limitations of this tool
- It only builds static header text—your framework may need middleware syntax (Express
cors(), Spring config, etc.). - It does not model dynamic origin allowlists, regex origins, or per-route policies—you must merge that logic yourself.
- CORS is not a substitute for authn/authz; permissive headers do not make an API safe.