CS FundamentalsVery hardProduct-company web interview
A web app at https://app.example.com sends a PUT request with a JSON body to https://api.example.com. Before the PUT, the browser sends another request. What is it, and why?
- A. An OPTIONS preflight request, because a cross-origin PUT with a JSON content type is not a 'simple' request, so the browser asks the server which methods and headers it allows
- B. A HEAD request to check the file size
- C. A GET request to fetch a CSRF token automatically
- D. No extra request is sent; CORS applies only to GET
Correct answer: A. An OPTIONS preflight request, because a cross-origin PUT with a JSON content type is not a 'simple' request, so the browser asks the server which methods and headers it allows
Different subdomains are different origins. For non-simple methods or headers the browser sends a CORS preflight (OPTIONS) and proceeds only if the response's Access-Control-Allow-* headers permit it.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- An API uses self-contained JWT access tokens that are valid for 24 hours and are verified only by signature. A user's laptop is stolen and…
- A token-bucket rate limiter holds up to 10 tokens and refills 2 tokens per second; it starts full. A client fires requests as fast as…
- main has A-B-C. feature1 branched from C with commits D-E, and feature2 branched from E with commits F-G. feature1 is abandoned, but…
- A developer edits a tracked file app.py, creates a new file util.py, and runs git commit -a -m "update". What is committed?
- A CI job runs git clone --depth 1 on a large repository. Which statement is correct?
- Assertion (A): Raising average server CPU utilisation from 50% to 95% to save cost usually makes response times much worse. Reason (R): In…