title: I am unable to set basic authentication headers
body: <p>I'm a newbie in angular. I'm trying to send a GET request to server with basic authentication headers, but it didn't work. Here is my code,</p>
  
  <pre><code>///////////////My app.js///////////////
  var myApp = angular.module('myApp', ['ngRoute', 'ui.bootstrap']);
  
  myApp.config(['$routeProvider', '$httpProvider', function($routeProvider, $httpProvider){
      $httpProvider.defaults.headers.common['Authorization'] = 'Basic YWRtaW46YWRtaW4=';
      $routeProvider
      .when('/', {
          controller: 'UserController',
          templateUrl: './app/views/homepage.html'
      })  
      .when('/users', {
          controller: 'UserController',
          templateUrl: './app/views/userlist.html'
      });
  }]);
  
  ///////////////My userService.js///////////////
  myApp.factory('UserService', function($http){
  var factory = {};
  var urlBase = 'http://xxx.xxx.xxx.xxx/api';
      factory.getUsers = function(){
          return $http.get(urlBase+'/getusers');
      };
      return factory;
  });
  </code></pre>
  
  <p>When I called the service from controller, There were 2 errors shown in the browser's console,</p>
  
  <ul>
  <li>OPTIONS <a href="http://xxx.xxx.xxx.xxx/api/getusers" rel="nofollow">http://xxx.xxx.xxx.xxx/api/getusers</a></li>
  <li>XMLHttpRequest cannot load <a href="http://xxx.xxx.xxx.xxx/api/getusers" rel="nofollow">http://xxx.xxx.xxx.xxx/api/getusers</a>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '<a href="http://localhost:3000" rel="nofollow">http://localhost:3000</a>' is therefore not allowed access. The response had HTTP status code 401.</li>
  </ul>
  
  <p>While I send request via POSTMAN app, it work normally. </p>
  
  <p>Thanks for help.</p>