title: error: "Unauthenticated." Laravel
body: <p>So I'm trying to store the id of my user in user_id but laravel gives the error:</p>
  
  <p>{error: "Unauthenticated."}</p>
  
  <p>while my user is logged in in my backoffice.</p>
  
  <p>this is my routesApi.php</p>
  
  <pre><code>Auth::routes();
  
  Route::group([
      'namespace' =&gt; 'Api',
      'prefix' =&gt; 'api/v1',
      'middleware' =&gt; 'web'
  ], function () {
      $options = [
          'except' =&gt; [
              'create',
              'edit',
          ]
      ];
  
      header('Access-Control-Allow-Origin: *');
      header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE');
      header('Access-Control-Allow-Headers: Content-Type, X-Auth-Token, Origin, Authorization, X-CSRF-TOKEN ');
  
  
      Route::middleware('auth')-&gt;post('optionelections', function (Request $request) {
          return $request-&gt;user();
      });
  });
  </code></pre>
  
  <p>and this is the function for my store in my controller:</p>
  
  <pre><code>public function store(Request $request)
      {
          $optionElection = new OptionElection();
          $optionElection-&gt;user_id = Auth::id();
          $optionElection-&gt;option = Auth::name();
          $optionElection-&gt;votes = 0;
          $optionElection-&gt;election_id = $request['election_id'];
          $optionElection-&gt;accepted = 0;
  
          if ($optionElection-&gt;save()) {
  
  
              return response()
                  -&gt;json($optionElection);
  
          }
  
      }
  </code></pre>