Security · cross-origin requests

CORS preflight.

Describe the request, paste the server's response headers, and see the decision a browser would make and the exact check that fails. Nothing is fetched or uploaded.

Fetch Standard CORS protocol + MDNSimulation from pasted headers · not a live test

Advertisement

Request and response

Browser decision

Run the check to see each step.

Advertisement

What this checks

Scope: this replays the Fetch Standard algorithm on the headers you paste. It does not contact your server, cannot see what a proxy or CDN changes in transit, and browsers add their own caps and extra rules (for example private-network access). Confirm with a real request in browser DevTools.

Fetch Standard: CORS protocol · MDN: CORS

What a CORS preflight is

Browsers stop a script on one origin from reading a response from another origin unless the other server opts in with CORS headers. For requests that could have side effects, the browser first sends a preflight: an automatic OPTIONS request carrying Origin, Access-Control-Request-Method and, when your code sets unusual headers, Access-Control-Request-Headers. Only if the server's answer allows the method and headers does the browser send the real request. You do not write the preflight yourself, and you cannot skip it from JavaScript; you can only make the server answer it correctly. This page replays that decision from the values you enter, so you can see which check fails without deploying anything.

When a preflight happens at all

A request skips the preflight only if it is "simple": the method is GET, HEAD or POST; the only headers your code sets are the CORS-safelisted ones (Accept, Accept-Language, Content-Language, Content-Type and a single-range Range); and any Content-Type is application/x-www-form-urlencoded, multipart/form-data or text/plain. The Fetch Standard also caps each safelisted header value at 128 bytes and the safelisted values together at 1,024 bytes. Anything else triggers a preflight. The two usual surprises are Content-Type: application/json, which is not safelisted, and an Authorization header.

How the check works, step by step

  1. The tool decides whether your method and headers make the request simple. If so, no preflight is needed and only the actual response headers matter.
  2. If a preflight is needed, it checks that the preflight status is an "ok" status (200 to 299). A 301, 401, 403 or 500 on the OPTIONS request fails the whole exchange.
  3. Access-Control-Allow-Origin must equal your page origin exactly (scheme, host and port), or be * for a request without credentials.
  4. For credentialed requests (cookies or HTTP authentication), the response must also send Access-Control-Allow-Credentials: true, and the wildcard * is not allowed for the origin, headers or methods.
  5. Access-Control-Allow-Methods must list the method (the safelisted methods are always allowed) and Access-Control-Allow-Headers must list each unsafe header you set. The Authorization header is special: a * in Allow-Headers does not cover it, so it must be named.
  6. Access-Control-Max-Age says how long the browser may cache the preflight result. If you omit it, the default is 5 seconds, so a chatty API repeats the OPTIONS call constantly.

Worked example

A page at https://app.example.com calls PUT https://api.example.com/items/7 with Content-Type: application/json and Authorization: Bearer token, without cookies. Both the method and the headers are unsafe, so a preflight happens. The API answers OPTIONS with status 204 and Access-Control-Allow-Origin: https://app.example.com, Access-Control-Allow-Methods: GET, PUT and Access-Control-Allow-Headers: Content-Type. Origin passes, method passes, Content-Type passes, but Authorization is missing from the allowed headers, so the browser blocks the request and the PUT never leaves. The fix is on the server: add Authorization to Access-Control-Allow-Headers. Changing the front-end code cannot fix it.

Common mistakes

What this tool does not cover

It does not contact your server and cannot see what a proxy, CDN or gateway changes in transit. Browsers also apply their own caps (Chromium limits the preflight cache to 2 hours, Firefox to 24 hours) and extra rules such as private-network access. Confirm the final answer with a real request in your browser's developer tools. For related header work, see the CSP generator and the security headers analyzer.

Advertisement

Common mix-ups

  1. MDN: Cross-Origin Resource Sharing (CORS)

Checked against these sources on .

Frequently asked questions

What is a CORS preflight request?

It is an automatic OPTIONS request that the browser sends before certain cross-origin requests, asking the server whether the real method and headers are allowed. The request carries Origin, Access-Control-Request-Method and, if needed, Access-Control-Request-Headers. The real request is only sent if the response approves it.

Why does my request send an OPTIONS request first?

Your request is not a simple request. Using a method other than GET, HEAD or POST, setting a header outside the safelisted set, or sending a Content-Type such as application/json all trigger a preflight. Adding an Authorization header does too.

How do I fix a CORS error about a header not being allowed?

Add the header name to Access-Control-Allow-Headers in the response to the OPTIONS request, not just the final response. Authorization must be listed by name, because the wildcard does not cover it. Then reload and test again.

Can I use Access-Control-Allow-Origin: * with cookies?

No. For requests with credentials the browser rejects the wildcard. Return the exact requesting origin, send Access-Control-Allow-Credentials: true, and add Vary: Origin so that caches do not serve one origin's answer to another.

How long does the browser cache a preflight?

Access-Control-Max-Age sets the number of seconds, and the default is 5 if you leave it out. Browsers cap the value: Chromium at 2 hours and Firefox at 24 hours. A larger value cuts repeated OPTIONS traffic, but changes to your CORS policy take longer to be seen.

Does the preflight response need a specific status code?

It must be an ok status, meaning 200 to 299, and 204 is common. Redirects, 401, 403 and 5xx responses make the browser treat the preflight as failed. Make sure authentication middleware and routing allow OPTIONS.

Why does the request work in curl or Postman but fail in the browser?

CORS is enforced by browsers. Tools like curl and Postman never perform the check, so they show only that the server responds. The browser also requires the right CORS headers before it lets your script read the answer.

Sources