Menu

CORS Example

.hakr.site

The two buttons above each call a JS function that makes a request to an endpoint on this site:

Use your dev tools to inspect the responses and look at the headers they contain. In these examples, no preflight OPTIONS request is needed because they are "simple" GET requests. Whether a request will trigger an OPTIONS request is determined by these rules:

Scenario OPTIONS Needed? Why?
GET request with standard headers ❌ No "Simple" request, no preflight needed.
POST with Content-Type: application/json ✅ Yes Non-standard Content-Type triggers a preflight.
PUT/DELETE request ✅ Yes Non-simple method triggers a preflight.
Request with an Authorization header ✅ Yes Custom header triggers a preflight.
Request with credentials (cookies) ✅ Yes Credentials require explicit preflight approval.