title: Return JSON response instead of 401 Blade file
body: <p>I am using AuthBasic for API authentication in a Laravel project,
  I have this problem: when the API request authentication is invalid instead of displaying the JSON response it returns the 401 default blade view template.</p>
  
  <p>Here is the code:</p>
  
  <p><strong>app\Http\Middleware\AuthBasic.php</strong></p>
  
  <pre><code>public function handle($request, Closure $next)
  {   
      if (Auth::onceBasic()) {
          return response()-&gt;json(["message", "Authentication Required!"], 401);
      } else {
          return $next($request);
      }
  }
  </code></pre>