Use CORS to Access Chatter REST API

Chatter REST API supports CORS (cross-origin resource sharing). To access this API from JavaScript in a Web browser, add the origin serving the script to the CORS whitelist.
Available in: Professional, Enterprise, Performance, and Developer

User Permissions Needed
To create, read, update, and delete: “Modify All Data”

To enable this feature, contact your Salesforce representative.

Note

CORS is a W3C recommendation that enables Web browsers to request resources from origins other than their own (cross-origin request). For example, using CORS, a JavaScript script at https://www.example.com could request a resource from https://www.salesforce.com.

If a browser that supports CORS makes a request to an origin in the Salesforce CORS whitelist, Salesforce returns the origin in the Access-Control-Allow-Origin HTTP header, along with any additional CORS HTTP headers. If the origin is not included in the whitelist, Salesforce returns HTTP status code 404.

  1. From Setup, choose Security Controls | CORS.
  2. Choose New.
  3. Enter an origin URL pattern.
    The origin URL pattern must include the HTTPS protocol and a domain name, and may include a port. The wildcard character (*) is supported and must be in front of a second-level domain name. For example, https://*.example.com adds all subdomains of example.com to the whitelist.
    The origin URL pattern can be an IP address. However, an IP address and a domain that resolve to the same address are not the same origin, and you must add them to the CORS whitelist as separate entries.

You must still pass an OAuth token with requests that require it.

Important