Skip to main content
InterviewHubPRO
Section Overview
Q10

Question 10 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

20%
Networking & Protocols (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

What is CORS (Cross-Origin Resource Sharing) and the Preflight Request?

junior LevelMost AskedSecurity & Auth

In Simple Words: A browser security mechanism enforcing the Same-Origin Policy:

  • An origin is defined by Protocol + Domain + Port.
  • If a frontend on https://myapp.com makes an API call to https://api.com:
  • Preflight Request: The browser automatically sends an HTTP OPTIONS request first:
    • Headers: Origin: https://myapp.com, Access-Control-Request-Method: POST.
    • The server must respond with Access-Control-Allow-Origin: https://myapp.com (or *).
    • If approved, the browser sends the actual POST request; if rejected, the browser blocks the response.