How do you enable cross origin resource sharing (CORS) for Sugar 7 REST API?

A recently asked question that I've decided to answer here in the community so all can benefit since I did not see it asked here previously.
How do you enable cross origin resource sharing for Sugar 7 REST API?
Cross Origin Resource Sharing (CORS) allows clients to selectively by-pass the Same-origin policy implemented by web browsers.  The Same-origin policy prevents web pages from accessing data from a different origin than the current one for security reasons.  In particular, this prevents any arbitrary JavaScript web app from calling the Sugar 7 REST API directly using AJAX.  CORS is the accepted standard for allowing cross origin requests that would otherwise be prevented.

For more details on what CORS means, check out this great resource.
http://enable-cors.org/index.html
Parents Reply Children