title: Unable to bypass CORS in angularjs seed app
body: <p>I'm using <a href="https://github.com/angular/angular-seed" rel="nofollow">angularjs-seed</a> app and I'm trying to get JSON response from server (MarkLogic) using <code>$http</code>. I've been on it for 3 days tried every response from other similar stackoverflow answers but not able to get it working. Please help!</p>
  
  <p>The browser returns this:</p>
  
  <pre><code>XMLHttpRequest cannot load http://sreddy:8003/v1/search?format=json. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access. 
  </code></pre>
  
  <p>Here's my app code</p>
  
  <p><strong>app.js</strong></p>
  
  <pre><code>'use strict';
  
  
  // Declare app level module which depends on filters, and services
  var app = angular.module('myApp', [
    'ngRoute',
    'myApp.filters',
    'myApp.services',
    'myApp.directives',
    'myApp.controllers'
  ]);
  
  app.config(['$routeProvider', '$httpProvider', function($routeProvider, $httpProvider) {
    $routeProvider.when('/view1', {templateUrl: 'partials/partial1.html', controller: 'MyCtrl1'});
    $routeProvider.when('/view2', {templateUrl: 'partials/partial2.html', controller: 'MyCtrl2'});
    $routeProvider.otherwise({redirectTo: '/view1'});
  
    // to avoid CORS
    $httpProvider.defaults.withCredentials = true;
    $httpProvider.defaults.useXDomain = true;
    delete $httpProvider.defaults.headers.common['X-Requested-With'];
  }]);
  </code></pre>
  
  <p><strong>controllers.js</strong></p>
  
  <pre><code>'use strict';
  
  /* Controllers */
  
  var app = angular.module('myApp.controllers', []);
  
  
  app.controller('MyCtrl1', ['$scope', 'dataService', function($scope, dataService) {
        $scope.test = "test";
        $scope.data = null;
        dataService.getData().then(function (dataResponse) {
            $scope.data = dataResponse;
        });
        console.log($scope.data);
    }]);
  
    app.controller('MyCtrl2', [function() {
        console.log("from MyCtrl2");
    }]);
  </code></pre>
  
  <p><strong>services.js</strong></p>
  
  <pre><code>'use strict';
  
  /* Services */
  
  
  // Demonstrate how to register services
  // In this case it is a simple value service.
  var app = angular.module('myApp.services', []);
  
  app.value('version', '0.1');
  
  app.service('dataService', function($http) {
  
  this.getData = function() {
      // $http() returns a $promise that we can add handlers with .then()
      return $http({
          method: 'GET',
          url: 'http://sreddy:8003/v1/search?format=json'
       });
   }
  });
  </code></pre>