CS FundamentalsVery hardGATE CS · Product company CS fundamentals

A page at https://app.example.com uses fetch() to send a PUT request with a JSON body to https://api.example.com. What happens first?

  1. A. An OPTIONS preflight; the PUT follows only if CORS headers allow it
  2. B. The browser sends the PUT immediately and blocks only the response
  3. C. The server must reply with 301 before the PUT
  4. D. Nothing special happens because both are subdomains of example.com

Correct answer: A. An OPTIONS preflight; the PUT follows only if CORS headers allow it

Different subdomains are different origins. PUT with a JSON content type is not a 'simple' request, so the browser asks permission with OPTIONS (Access-Control-Request-Method) and proceeds only if Access-Control-Allow-Origin/Methods permit it.

More Computer Networks questions

Exams that ask this topic