CORS Header Generator & Tester — Fix “Blocked by CORS Policy”

Seeing “has been blocked by CORS policy”? Describe who may call your API — origins, methods, headers, credentials — and get the right Access-Control-* headers as code for Express, Nginx, Apache, Netlify, Vercel, Next.js, Cloudflare Workers or PHP. Then test a live URL: the tester sends the same preflight a browser would and explains, header by header, whether the request is allowed.

Runs on our serverUpdated
CORS config

This tool fetches the public URL you enter from our server. Results are held in temporary memory for a few minutes and never stored in a database.

How to use the CORS Header Generator & Tester

  1. On Generate headers, list the origins that may call your API (or allow any), tick the methods, and enter the request headers your front end sends — usually Content-Type and Authorization.
  2. Tick Allow credentials only if the browser must send cookies or an Authorization header with credentials: 'include'.
  3. Pick your platform and copy the code — Express, Nginx, Apache, Netlify, Vercel, Next.js, Workers or PHP.
  4. Deploy, then switch to Test a URL: enter the API URL and the page’s origin to see whether the preflight and the real request would pass.

Why browsers block requests

A page on https://app.example.com can only read a response from https://api.example.com if the API says so with CORS headers. For anything beyond a simple GET or form POST — JSON bodies, Authorization headers, PUT or DELETE — the browser first sends a preflight: an OPTIONS request asking “may this origin use this method and these headers?”. If the answer is missing or wrong, you see “has been blocked by CORS policy” and your code never gets the response.

HeaderWhat it must contain
Access-Control-Allow-OriginThe calling origin exactly, or * (not allowed with credentials)
Access-Control-Allow-MethodsThe method of the real request (preflight only)
Access-Control-Allow-HeadersEvery non-standard request header, such as Authorization or Content-Type: application/json
Access-Control-Allow-Credentialstrue when cookies or credentials are sent
Access-Control-Max-AgeHow long the browser may cache the preflight answer
Vary: OriginNeeded when the allowed origin changes per request, so caches don’t serve one origin’s answer to another

How the tester works

Our server sends the request with an Origin header and, if the browser would need one, an OPTIONS preflight with Access-Control-Request-Method and -Headers — the same as Chrome or Firefox. It then checks the answer against the CORS rules browsers apply. Servers that only allow certain IP addresses or need cookies may answer differently for real users. Related: HTTP Header Checker, API Tester, Security Headers Checker.

Also searched as: cors header generator, cors tester, cors checker, blocked by cors policy, access-control-allow-origin, cors preflight test, express cors, nginx cors.

Tools that pair well with the CORS Header Generator & Tester

  • CSP Generator — Pick what your site loads — scripts, styles, images, fonts, analytics, embeds — and get a Content-Security-Policy that allows exactly that, with warnings for risky settings.
  • cURL to Code — Paste a curl command — from API docs or “Copy as cURL” in your browser’s DevTools — and get ready-to-run code for six languages, with headers, body and authentication carried over.
  • Email Header Analyzer — Paste the raw headers of an email to see its whole journey: every server hop with the time it took, the SPF, DKIM and DMARC results, the originating IP, and warning signs like a mismatched Reply-To or Return-Path.
  • MIME Type Lookup — Search 200+ file extensions and MIME types — .webp, .woff2, .webmanifest, application/wasm … — or drop a file to detect its real type from its first bytes.

Frequently asked questions

How do I fix “No Access-Control-Allow-Origin header is present”?
The API must send Access-Control-Allow-Origin with your page’s origin (or *). Generate the config for your server here, deploy it, and run the tester to confirm. The fix always goes on the API server, never in the front-end code.
Why can’t I use * with credentials?
Browsers refuse Access-Control-Allow-Origin: * when the request includes cookies or credentials. List the exact origins instead (or echo the request’s Origin after checking it) and send Access-Control-Allow-Credentials: true.
Why does my API return 404 or 405 for OPTIONS?
The preflight is an OPTIONS request your routes may not handle. It must return 2xx with the CORS headers — the generated code answers OPTIONS with 204.
Is it safe to allow any origin?
For public, read-only APIs without cookies, * is fine. For anything that uses logins or cookies, allow only the origins you trust — echoing any origin with credentials lets every website act as your logged-in users.

Related tools