Promptles
Backend & APIs

CORS (Cross-Origin Resource Sharing)

intermediate

Definition

A safety rule built into web browsers. By default, a website at one address isn't allowed to grab data from a website at a different address. CORS is the way the second site can say 'it's okay, I trust this other site to read my data.' If the permission isn't there, the browser blocks the request.

In the wild

A small weather website tries to fetch live data from a public weather service. The browser refuses until the weather service includes a header in its responses that basically says, 'visitors from this website are welcome to read my data.'

More from Backend & APIs