CORS Header Generator
Generate correct CORS headers for Apache, Nginx, PHP or Express — with credential-mode validation built in.
Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.
About this tool
CORS errors block more launches than almost anything else — and most "fixes" pasted from forums are subtly wrong. This generator builds a correct CORS configuration for your stack: allowed origin, methods, headers, max-age and credentials, plus the preflight OPTIONS handling most snippets forget.
It also refuses invalid combinations, like wildcard origin together with credentials, explaining why browsers reject them.
How to use it
- Enter your allowed origin (use a real origin, not *, if you send cookies).
- List the methods and request headers your API accepts.
- Pick your target: Apache .htaccess, Nginx, PHP or Node/Express.
- Copy the config — preflight handling is included.
Useful ways to apply it
- Fixing "blocked by CORS policy" errors on a new API.
- Allowing a JS frontend on one domain to call an API on another.
- Configuring shared hosting (.htaccess) without server access.
- Standardizing CORS across environments with one source of truth.
Worked example
Example input
Origin https://app.example.com; credentials yes; methods GET, POST
Expected output
Access-Control-Allow-Origin: https://app.example.com; Access-Control-Allow-Credentials: true
Edge cases to check
- Wildcard origin cannot be used for credentialed requests.
- Reflecting every Origin header without an allowlist is unsafe.
- Preflight responses need correct allowed method/header handling and Vary behavior.
Known limitations
Generated headers are a starting point. CORS must be enforced by server logic that knows which origins are actually trusted.
How this tool was reviewed
Reviewed against simple requests, credentialed requests, preflight flows and wildcard-origin rejection.
Standards and technical references
See the site-wide testing methodology for fixture categories, privacy checks and correction policy.
Frequently asked questions
Why can't I use * with credentials?
What is Access-Control-Max-Age?
Do I still need server-side auth?
Privacy
Tool input is processed locally in your browser and is not submitted to CodeNimbleTools. Avoid pasting production secrets into any device or website you do not fully trust.