What is ‘CORS’? What is it used for?

One of the first features I worked on at my job as a software engineer was to provide support for CORS requests in our product, the [Zenko CloudServer What is CORS? I thought. What is it used for? Before I could start working on this feature, I had to build up a knowledge of what CORS was in the first place.

“CORS” stands for C ross-O rigin R esource S haring. It allows you to make requests from one website to another website in the browser, which is normally prohibited by another browser policy called the Same-Origin Policy (SOP).

Recently, the topic of CORS resurfaced at work, when one of our contractors was having problems making a request to the CloudServer API in a browser. CORS was the answer to this problem, and since it’s a problem that other junior developers may encounter when working with APIs in the browser, I thought I would share what I’ve learned in case it might be helpful. :blush:

Disclaimer: I have gathered the information I’m presenting here from an amalgam of resources already out there on the web (linked at the bottom of this post). Please don’t hesitate to correct or clarify misleading information if you spot a misunderstanding!