Skip to the page

Web security · Concept

CORS and the same-origin policy

The interviewer asks

What is CORS? Why does my fetch to api.example.com work in Postman but fail in the browser? What is a preflight?

Then

Follow-ups the interviewer asks next

  1. Simple vs preflighted requests (methods, headers, content types).
  2. Access-Control-Allow-Credentials can't be combined with *.
  3. Caching preflights (Access-Control-Max-Age).
  4. Dev proxy vs fixing the server.

The answer

What a strong answer covers

  • The same-origin policy is a browser rule; CORS is a server opt-in through response headers
  • Origin = scheme + host + port
  • CORS is not authentication and does not protect the server

The red pen

Common traps

Avoid:"CORS is a server security feature that blocks requests" (the request often reaches the server).

Practise this out loud

Say your answer out loud to an AI interviewer that follows up, and get a score for it.

Practise by voice

Practise questions like this out loud

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview