- What is the same-origin policy?
- Browsers block scripts from reading data across different origins (protocol+host+port). CORS is how a server explicitly opts into cross-origin access.
- Simple vs preflight?
- Simple requests (GET/POST with specific headers) go direct. Preflight (OPTIONS) is sent first for anything with custom headers, PUT/DELETE, etc.
- What headers matter?
- Server side: Access-Control-Allow-Origin, -Methods, -Headers, -Credentials. Client side: withCredentials flag controls cookie inclusion.
- Why does CORS fail mysteriously?
- Common: the server allows origin * but also sets Access-Control-Allow-Credentials: true (forbidden combo). Or the preflight OPTIONS request is blocked by middleware.