# How to Debug a Failed CORS Preflight

> Diagnose a failed CORS OPTIONS preflight by checking the requested origin, method, headers, credentials, redirects, and proxy behavior.

Source: https://howhttpworks.com/debug/cors-preflight
Last reviewed: 2026-11-06

Error messages this page covers:
- `Access to fetch at 'https://api.example.com/widgets' from origin 'https://app.example.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.`
- `Access to fetch at 'https://api.example.com/widgets' from origin 'https://app.example.com' has been blocked by CORS policy: Request header field authorization is not allowed by Access-Control-Allow-Headers in preflight response.`
- `Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.example.com/widgets. (Reason: CORS preflight response did not succeed). Status code: 401.`

> **TL;DR:** A preflight failure means the browser never got permission to send your real request. Find the `OPTIONS` request in DevTools, replay it with curl, and check that it returns a 2xx with an allowed origin, method and headers. The usual culprit is authentication, a redirect or a proxy answering `OPTIONS` before your CORS handler does.

## 1. Find the OPTIONS request

Open DevTools, select Network, and filter for `OPTIONS`. Inspect the preflight separately from the GET, POST, PUT, PATCH or DELETE you meant to send. Three request headers matter:

- `Origin`: the exact scheme, host and port making the request.
- `Access-Control-Request-Method`: the method the browser wants to send.
- `Access-Control-Request-Headers`: the non-safelisted headers the browser wants to include.

A JSON `Content-Type`, an `Authorization` header, or a method such as PUT or DELETE triggers a preflight. The preflight itself is normal browser behavior, not the error.

## 2. Reproduce the browser's preflight

Send the same origin, method and header names that DevTools shows:

```bash
curl -i -X OPTIONS 'https://api.example.com/widgets' \
  -H 'Origin: https://app.example.com' \
  -H 'Access-Control-Request-Method: POST' \
  -H 'Access-Control-Request-Headers: content-type,authorization'
```

curl does not enforce CORS, which is exactly why it is useful here: you see the server's raw answer. It does not prove the browser will accept that answer, so compare each returned header with what the browser asked for.

## 3. Validate every allow header

Any 2xx status works for a preflight; `204 No Content` is the common choice:

```http
HTTP/2 204
Access-Control-Allow-Origin: https://app.example.com
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
Access-Control-Allow-Credentials: true
Vary: Origin
```

| Check | Failure to look for |
| --- | --- |
| HTTP status | A redirect, 401, 403, 404 or 500 instead of a 2xx ("It does not have HTTP ok status") |
| Allowed origin | Missing, a trailing-slash mismatch, or `*` together with credentials |
| Allowed method | The requested method is absent from `Access-Control-Allow-Methods` |
| Allowed headers | A requested header such as `Authorization` is absent from `Access-Control-Allow-Headers` |
| Credentials | The request sends cookies but `Access-Control-Allow-Credentials: true` is absent |

Header names are case-insensitive, but the values still have to cover what the browser requested. When the allowed origin is chosen dynamically, return the validated origin and add `Vary: Origin` so a shared cache never serves one site's answer to another.

## 4. Check routers, authentication, redirects and proxies

`OPTIONS` has to reach the code that answers CORS. The classic failure is authentication middleware that runs first: the preflight carries no credentials, gets a 401, and the browser reports a CORS error.

- Handle `OPTIONS` for the same URL as the real endpoint, ahead of authentication.
- Look for an HTTP-to-HTTPS or trailing-slash redirect on the route. A preflight may not follow redirects.
- Confirm the CDN, load balancer, WAF or reverse proxy forwards `OPTIONS` and keeps the CORS headers.
- Inspect error responses too. A proxy-generated 403 or 500 without CORS headers looks like a CORS failure to the browser.

## 5. Verify the actual response after the preflight succeeds

A successful preflight only lets the browser send the next request. That actual response must still carry a matching `Access-Control-Allow-Origin` and, when credentials are used, `Access-Control-Allow-Credentials: true`. Check both entries in the Network panel before calling it fixed.

Paste the request details into the [CORS Debugger](https://howhttpworks.com/tools/cors-debugger) for a policy check. If the error is about the missing header on the actual response rather than the preflight, continue with [No 'Access-Control-Allow-Origin' header](https://howhttpworks.com/debug/cors-no-access-control-allow-origin).
