The browser console shows a CORS error when your frontend calls your API. What is it and how do you fix it?
BeginnerScenarioTLS, HTTP & Application Layer
Answer
Situation read → CORS is enforced by the browser, not the network; the API must say which origins may read the response.
What I'd do →
- Check the error:
has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header - Inspect the preflight:
curl -i -X OPTIONS https://api.example.com/v1/items -H 'Origin: https://app.example.com' -H 'Access-Control-Request-Method: POST' - Return
Access-Control-Allow-Origin: https://app.example.com, allowed methods and headers - Make sure the OPTIONS request is not blocked by auth or the gateway
Why → The server opts in to cross-origin reads with headers; a wildcard with credentials is rejected by browsers.
Interview tip → Say CORS is not a security control for the API itself.
More on TLS, HTTP & Application Layer
Explain what happens in a TLS 1.3 handshake in a few sentences.BeginnerYour site must redirect all HTTP traffic to HTTPS. How do you do it?BeginnerWhat is the difference between 4xx and 5xx errors, and which ones do you see most in networking problems?BeginnerHTTP/1.1, HTTP/2 and HTTP/3: what changed and why does it matter in operations?BeginnerHow do you check which certificate a server presents and when it expires?BeginnerWhat is the difference between HTTP keep-alive and a new TCP connection per request?Beginner