How does CORS behave for requests made from a mobile app, server-to-server call, or a tool like curl/Postman, compared to a browser-based web app?
Short answer
CORS is exclusively a browser-enforced restriction -- it has no effect whatsoever on non-browser HTTP clients like mobile apps, server-to-server calls, or tools like curl/Postman, since there's no browser present to enforce the same-origin policy or send preflight requests --…
Advertisement
AModel answer
CORS is exclusively a browser-enforced restriction -- it has no effect whatsoever on non-browser HTTP clients like mobile apps, server-to-server calls, or tools like curl/Postman, since there's no browser present to enforce the same-origin policy or send preflight requests -- this is a common point of confusion, since CORS is purely a client-side browser convenience/safety mechanism, not genuine API security, and a non-browser client can simply ignore it entirely.
Example
// This works perfectly fine from a mobile app or curl, with ZERO CORS restrictions: // curl https://api.mycompany.com/orders -H "Authorization: Bearer xyz" // No preflight, no Origin header check -- CORS simply doesn't apply outside a browser
Real-world example
A security review corrects a misconception that a strict CORS policy was 'protecting' an API, clarifying that anyone using Postman, curl, or a mobile app can call the API directly with zero CORS restrictions -- real authorization checks are the actual security boundary, not CORS.
Likely follow-ups
- What IS the actual security boundary if CORS doesn't protect against non-browser clients?
- Why do developers commonly conflate CORS with API security?
Related topics