title: 401 error using HTTP basic auth with Axios in Vuejs
body: <p>I'm working on a Vuejs app that gets its data from an Apache Solr index, and I have had my app working with the index using <a href="https://github.com/axios/axios" rel="nofollow noreferrer">Axios</a> to make the connection. However, HTTP basic authentication has been added, and I am unable to get authentication to work. The <code>Access-Control-Allow-Origin</code> header is set on the server (it worked prior to adding the auth to the index), so that is not an issue. I am attempting to use the <code>auth</code> object in the config object in <code>axios.get()</code> like  so:</p>
  
  <pre><code>const params = new URLSearchParams()
  params.append('fl', 'label,bundle,entity_id,ss_language,url,is_product_slideshow')
    if (this.nodeType) {
      params.append('fq', 'bundle:' + this.nodeType)
    } else {
      params.append('fq', 'bundle:' + '(article OR document OR video OR product_display)')
    }
    params.append('fq', 'ss_language:' + this.language)
    params.append('fq', 'bs_status:' + 1)
    params.append('fq', '-is_field_restricted_to_internal_use:1')
    params.append('fq', '-is_field_restricted_to_author_of_as:1')
    params.append('fq', '-is_field_pp_confidential:1')
    params.append('fq', '-is_field_pp_do_not_show_item_on_t:1')
    params.append('q', qs)
    params.append('sort', 'is_sort asc')
    params.append('wt', 'json')
    params.append('rows', 10)
    params.append('start', queryStartRows)
    axios.get('https://my-solr-url.com/solr/my-solr-index/select', {
      params: params,
      withCredentials: true,
      auth: {
        username: 'myusername',
        password: 'mypassword'
      }
    })
    .then(response =&gt; {
      this.results = response.data.response.docs
      var numFound = this.numFound = response.data.response.numFound
      // Calculate last page.
      var numFoundRounded = Math.floor(numFound / 10) * 10
      var numPages = numFoundRounded / 10
      this.lastPage = numPages
    })
  </code></pre>
  
  <p>I can get the query to run fine from Postman, so I know I have the correct credentials.</p>
  
  <p>From what I can tell from the docs and other examples, I'm doing it right, but I'm still getting a 401 error. </p>
  
  <p>I also use this index from a Drupal site, and there, the user id and password are passed as part of the URL:</p>
  
  <pre><code>https://myusername:mypassword@my-solr-url.com/solr/my-solr-index/select?...
  </code></pre>
  
  <p>but that approach doesn't work here, either. What do I need to do differently to get the authentication to work?</p>