title: API requests with axios always unauthorized with Laravel API
body: <p>I'm working on a personal project using <a href="https://laravel.com/" rel="noreferrer">Laravel</a> 5.6 and <a href="https://github.com/axios/axios" rel="noreferrer">Axios</a> library (standard Laravel <a href="https://laravel.com/docs/5.6" rel="noreferrer">5.6</a> package). </p>
  
  <p>I need to send first GET then POST request using Laravel's API and axios' http requests, but I'm not using Passport or any library like that since it's an internal API serving only VueJS to obtain stuff from the database.</p>
  
  <p>If I set my API routes using <code>auth:api</code> middleware, I always get unauthorized response, whichever is the request type, this is the error output :</p>
  
  <blockquote>
    <p>Error: Request failed with status code 401</p>
  </blockquote>
  
  <p>The message :</p>
  
  <pre><code>message: "Unauthenticated."
  </code></pre>
  
  <p>But, as I read in the documentation, axios headers are set inside laravel's <code>bootstrap.js</code> to read the authorization token from meta tags (and the code is there) :</p>
  
  <pre><code>window.axios = require('axios');
  
  window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
  
  // further down the file...
  let token = document.head.querySelector('meta[name="csrf-token"]');
  
  if (token) {
      window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
  } else {
      console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
  }
  </code></pre>
  
  <p>While, if needed, here's the http request code :</p>
  
  <pre><code>axios.post('/api/latest', formData)
  </code></pre>
  
  <p>So, why am I unauthenticated if those are set?</p>
  
  <p>I've tried removing the <code>auth:api</code> middleware and, of course, it's working:</p>
  
  <pre><code>- Route::middleware('auth:api')-&gt;get('/latest', 'InternalApiController@latestEp');
  + Route::get('/latest', 'InternalApiController@latestEp');
  </code></pre>
  
  <p>What am I doing wrong?</p>