CORS = Cross-Origin Resource Sharing
A browser security mechanism that controls whether a webpage on one origin can request resources from a different origin.
Origin = Protocol + Domain + Port
<https://example.com:443>
^ ^ ^
protocol domain port
Same origin — all three must match exactly.
Different origin examples:
http://other.example.com — different subdomainhttps://example.com vs http://example.com — different protocolhttp://example.com:8080 — different portOPTIONS /
Host: www.other.com
Origin: <https://www.example.com>
Browser is asking: "Am I allowed to fetch from you?"
Access-Control-Allow-Origin: <https://www.example.com>
Access-Control-Allow-Methods: GET, PUT, DELETE
Server says: "Yes, that origin is allowed."