Debug a CORS Preflight Failure
Scenario
The browser console shows a CORS error — something like "No 'Access-Control-Allow-Origin' header is present" — but the network tab in devtools doesn't make it obvious which response header is missing or misconfigured. You need to see the actual preflight request and response the browser sent and received.
Steps
Start the proxy:
laurel-proxy startIf the target API uses HTTPS, trust the CA certificate so Laurel Proxy can decrypt the traffic:
laurel-proxy trust-caReproduce the failing request in your browser (with the proxy configured as your system proxy), then query for the preflight:
laurel-proxy requests --method OPTIONS --host api.example.com --format agentThe --method OPTIONS flag filters to only preflight requests. The --format agentoutput includes the full response headers, so you can read the Access-Control-* values directly instead of reconstructing them from devtools.
Example output:
{
"summary": "OPTIONS https://api.example.com/v1/users → 204 (took 12ms)",
"request": {
"method": "OPTIONS",
"headers": {
"origin": "http://localhost:5173",
"access-control-request-method": "POST",
"access-control-request-headers": "content-type,authorization"
}
},
"response": {
"status": 204,
"headers": {
"access-control-allow-origin": "https://app.example.com",
"access-control-allow-methods": "GET,POST",
"access-control-allow-headers": "content-type"
}
}
}Compare the request headers against the response headers. Common mismatches:
Access-Control-Allow-Origindoesn't match theOriginthe browser sent (as above —localhost:5173vs. the allowedapp.example.com)Access-Control-Allow-Headersis missing a header the request sends, such asauthorizationAccess-Control-Allow-Methodsdoesn't include the method the actual request will use- The preflight itself returns a non-2xx status, so the browser never sends the real request
With Your AI Agent
With the AI Agent Plugin, describe the CORS error and let your agent trace it:
You: "Requests to api.example.com are failing with a CORS error. Debug it."
Your agent queries: laurel-proxy requests --method OPTIONS --host api.example.com --format agent
The agent compares the Origin header on the request against the
Access-Control-Allow-Origin on the response, spots the mismatch, and
updates your server's CORS configuration.Your agent sees both sides of the preflight handshake in one query, instead of you manually diffing headers in devtools.
Related
- CLI Reference - All commands, flags, and output formats
- Debug 422 Errors - Trace validation failures back to the request
- HTTPS Interception - Decrypt HTTPS traffic to see real headers
- AI Agent Plugin - AI-assisted HTTP debugging in your terminal