CORS
Also called: Cross-Origin Resource Sharing, CORS preflight, same-origin policy
Cross-Origin Resource Sharing is a browser-enforced protocol that lets a server declare which origins may read a response through web APIs. An origin is defined by scheme, host and port. Response fields such as Access-Control-Allow-Origin express permission; some requests first require an OPTIONS preflight.
A page at https://app.example might fetch data from https://api.example. The API’s response must satisfy CORS checks before the browser exposes it to that page’s script. CORS is not user authorization or a general firewall: some requests can be sent without preflight, and non-browser clients do not enforce the browser’s same-origin restrictions.
- Read first
- HTTP headers
- Related
- HTTP headers, HTTP cookies, Authorization
- Further reading
- WHATWG Fetch — CORS protocol