title: Axios: Cannot make call to API with Basic Auth
body: <p>I'm trying to issue a CORS <code>get</code> request in Vue via axios. Everything works well so far, but if I need to authenticate via basic auth, I cannot get it to work.</p>
  
  <p>Heres my code</p>
  
  <pre><code>getData: function() {
    let vm = this; // assign vue instance to vm
  
    axios.get('url', {
      withCredentials: true,
      auth: {
        username: 'name',
        password: 'pass'
      }
    }).then(function(response) {
      console.log(response)
    }).catch(function(error) {
      console.log(error)
    }) 
  }
  </code></pre>
  
  <p>Even though I entered the credentials, as well as the url correctly, I <em>always</em> get a 401 response. It looks like this.</p>
  
  <pre><code>HTTP/1.1 401 Authorization Required
  Date: Wed, 01 Feb 2017 16:23:31 GMT
  WWW-Authenticate: Basic realm="'Realm'"
  Content-Length: 499
  Keep-Alive: timeout=15
  Connection: Keep-Alive
  Content-Type: text/html; charset=iso-8859-1
  </code></pre>
  
  <p>The raw request looks like that</p>
  
  <pre><code>OPTIONS 'url' HTTP/1.1
  Host: 'host'
  Connection: keep-alive
  Pragma: no-cache
  Cache-Control: no-cache
  Access-Control-Request-Method: GET
  Origin: http://localhost:9000
  User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3)
  AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76
  Safari/537.36
  Access-Control-Request-Headers: authorization
  Accept: */*
  DNT: 1
  Referer: http://localhost:9000/pages/blog_cc/blog_cc.html
  Accept-Encoding: gzip, deflate, sdch, br
  Accept-Language: de,en;q=0.8
  </code></pre>
  
  <p>What am I missing? With Postman and the exact same credentials, everything works like a charm. Even in Chrome directly.</p>
  
  <p>I saw that this question was already asked a few times, but all the posed answers on other threads are no solution for me. I cannot issue the request from node, for example.</p>
  
  <p>Edit: I also tried issuing a request with vanilla JS, also to no avail. It seems the problem lies in the backend. Here's my code, nevertheless.</p>
  
  <pre><code>let xml = new XMLHttpRequest();
  xml.open('GET', api, true);
  xml.setRequestHeader('Authorization', 'Basic: ' + btoa(user + ':' + pass));
  xml.send();
  </code></pre>