Protocols
Saved & recent

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
page script cross-origin API browser boundary preflight when required resource request response + Access-Control-Allow-Origin browser access check exposed to script withheld from script
The browser checks the API response before exposing it to the page’s script. Some requests first require a preflight; failed CORS checks do not imply that every request was stopped before reaching the API. Authorization remains separate.

View in the full Protocols collection