title: How to configure the $http service in Angular depending on itself?
body: <p>I'm trying to configure the <code>$http</code> service of Angular, to redirect to an URL when the status code is 403.</p>
  
  <p>No problems so far but the URL to redirect to is coming from the server, through a service which is using <code>$http</code> (obiously).</p>
  
  <p>Here's a piece of code:</p>
  
  <pre><code>angular
  .module('app')
  .config(['$httpProvider', function($httpProvider) {
    $httpProvider.interceptors.push(['$q', 'URLs',
      function($q, Redirect) {
        return {
          request: function(config) {
            return config || $q.when(config);
          },
          responseError: function(response) {
            if(response.status === 403) {
              // redirect to URLs.login
            }
            return $q.reject(response);
          }
        };
      }
    ]);
  }])
  .factory('URLs', ['$http', function($http) {
    var URLs;
    $http.get('/urls').then(function(response) {
      URLs = response.data;
    });
    return URLs;
  }]);
  </code></pre>
  
  <p>This code is creating a circular dependency (error) in Angular.</p>
  
  <p>Is there a way that I can do this, having dynamic URLs that are coming from a server and based on this to redirect the user to one of them when the <code>response.status</code> is 403?</p>