Skip to main content
InterviewHubPRO
Section Overview
Q42

Question 42 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

84%
Networking & Protocols (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

Cross-Origin Resource Sharing (CORS): Simple requests vs Preflight `OPTIONS`.

senior LevelMost AskedSecurity & Auth

In Simple Words: A browser security mechanism enforcing the Same-Origin Policy (Protocol, Domain, Port):

  • Simple Requests (GET/POST with standard headers): Browser sends request directly, including Origin header. Server responds with Access-Control-Allow-Origin.
  • Preflight Requests (OPTIONS): Triggered if the request uses custom headers (e.g. Authorization, Content-Type: application/json) or mutating methods (PUT, DELETE):
    • Browser automatically fires a preflight OPTIONS request first: "Are you willing to accept a PUT request with an Authorization header from example.com?"
    • The actual data request executes only after the server approves the preflight headers.