Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I've created an AngularJS service that is hitting the Salesforce REST API directly from the client. However, I haven't been able to get it working due to same origin restrictions. Even when accessing non authenticated REST services and trying both $http, $http.json and Ajax. I've also tried lots of combinations of Json, Jsonp etc.

Given that I've had so many issues I'm thinking that my general approach is incorrect. Perhaps I need to setup a proxy server for this? My backend is Firebase so I don't currently have my own server.

I don't believe that the Salesforce API supports CORs and I cannot change that.

Here is an example of what I tried using $http and Ajax.

return $http.jsonp('',{

headers: {

    'Content-type': 'application/json', 'Accept': 'application/json'


                success(function (data, status, headers, config) {




                error(function (data, status, headers, config) {

                    console.debug("getVersions: failed to retrieve data: "+eval(data));



              url: '',

          type: "GET",

              dataType: "jsonp",

              beforeSend: function(xhrObj){



                                  xhrObj.setRequestHeader("X-Requested-With", "XMLHttpRequest");


              success: function (data) {




              error: function(data) {



1 Answer

0 votes
by (32.1k points)
edited by

For this, you'll have to go into Remote Settings within SalesForce then go to CORS and then whitelist the domain name...

I had the same issue and it seemed to have resolved the issue.

Do you want to build a career in Salesforce? Enroll in this Salesforce certification course to start your journey!

Related questions

+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories