title: Laravel Passport auth:api middleware results in  Route [login] not defined
body: <p>I have been keeping on getting  Route [login] not defined when I <strong>try</strong> do an HTTP post to the <strong>API\Usercontroller@details</strong></p>
  
  <p>I'm not sure why this is happening as when I look it up nothing related to this issue shows up.</p>
  
  <p>I have been following this tutorial: <a href="https://medium.com/techcompose/create-rest-api-in-laravel-with-authentication-using-passport-133a1678a876" rel="nofollow noreferrer">https://medium.com/techcompose/create-rest-api-in-laravel-with-authentication-using-passport-133a1678a876</a></p>
  
  <p>I have followed the installation guide from <a href="https://laravel.com/docs/7.x/passport" rel="nofollow noreferrer">https://laravel.com/docs/7.x/passport</a></p>
  
  <p><strong>THE RESULT I WANT</strong></p>
  
  <p><a href="https://i.stack.imgur.com/Zy0At.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Zy0At.png" alt="enter image description here"></a></p>
  
  <p><strong>WHAT I GOT INSTEAD</strong></p>
  
  <p><a href="https://i.stack.imgur.com/8a4Qs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8a4Qs.png" alt="enter image description here"></a></p>
  
  <p>api.php</p>
  
  <pre><code>&lt;?php
  
  use Illuminate\Http\Request;
  use Illuminate\Support\Facades\Route;
  
  /*
  |--------------------------------------------------------------------------
  | API Routes
  |--------------------------------------------------------------------------
  |
  | Here is where you can register API routes for your application. These
  | routes are loaded by the RouteServiceProvider within a group which
  | is assigned the "api" middleware group. Enjoy building your API!
  |
  */
  
  Route::post('login', 'API\UserController@login');
  Route::post('register', 'API\UserController@register');
  
  Route::group(['middleware' =&gt; 'auth:api'], function(){
      Route::post('details', 'API\UserController@details');
  });
  </code></pre>
  
  <p>UserController.php</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Controllers\API;
  
  use App\Http\Controllers\Controller;
  use App\User;
  use Illuminate\Http\Request;
  use Illuminate\Support\Facades\Auth;
  use Validator;
  use Illuminate\Support\Facades\Hash;
  
  class UserController extends Controller
  {
      public $successStatus = 200;
  
      public function login()
      {
          $validator = Validator::make(request()-&gt;all(), [
              'email' =&gt; 'email|required',
              'password' =&gt; 'required',
          ]); 
  
          if ($validator-&gt;fails()) {
              return response()-&gt;json(['error' =&gt; $validator-&gt;errors()], 401);
          }
  
          if (Auth::attempt($validator-&gt;valid())) {
              $user = Auth::user();
              $success['token'] = $user-&gt;createToken('authToken')-&gt;accessToken;
              return response()-&gt;json(['success' =&gt; $success], $this-&gt;successStatus);
          } else {
              return response()-&gt;json(['error' =&gt; 'Unauthorized'], 401);
          }
      }
  
      public function register(Request $request)
      {
          $validator = Validator::make($request-&gt;all(), $this-&gt;rules());
  
          if ($validator-&gt;fails()) {
              return response()-&gt;json(['error' =&gt; $validator-&gt;errors()], 401);
          }
  
          $input = $validator-&gt;valid();
          $input['password'] = Hash::make($input['password']);
          $user = User::create($input);
          $success['token'] = $user-&gt;createToken('authToken')-&gt;accessToken;
          $success['name'] = $user-&gt;name;
          return response()-&gt;json(['success' =&gt; $success], $this-&gt;successStatus);
      }
  
      public function details() 
      { 
          return response()-&gt;json(['success' =&gt; Auth::user()], $this-&gt; successStatus); 
      }
  
      public function rules()
      {
          return [
              'name' =&gt; 'required',
              'email' =&gt; 'required|email|unique:users',
              'password' =&gt; 'required',
              'c_password' =&gt; 'required|same:password',
          ];
      }
  }
  </code></pre>
  
  <p>Kernel.php</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http;
  
  use Illuminate\Foundation\Http\Kernel as HttpKernel;
  
  class Kernel extends HttpKernel
  {
      /**
       * The application's global HTTP middleware stack.
       *
       * These middleware are run during every request to your application.
       *
       * @var array
       */
      protected $middleware = [
          \App\Http\Middleware\TrustProxies::class,
          \Fruitcake\Cors\HandleCors::class,
          \App\Http\Middleware\CheckForMaintenanceMode::class,
          \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
          \App\Http\Middleware\TrimStrings::class,
          \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
      ];
  
      /**
       * The application's route middleware groups.
       *
       * @var array
       */
      protected $middlewareGroups = [
          'web' =&gt; [
              \App\Http\Middleware\EncryptCookies::class,
              \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
              \Illuminate\Session\Middleware\StartSession::class,
              // \Illuminate\Session\Middleware\AuthenticateSession::class,
              \Illuminate\View\Middleware\ShareErrorsFromSession::class,
              \App\Http\Middleware\VerifyCsrfToken::class,
              \Illuminate\Routing\Middleware\SubstituteBindings::class,
          ],
  
          'api' =&gt; [
              'throttle:60,1',
              \Illuminate\Routing\Middleware\SubstituteBindings::class,
          ],
      ];
  
      /**
       * The application's route middleware.
       *
       * These middleware may be assigned to groups or used individually.
       *
       * @var array
       */
      protected $routeMiddleware = [
          'auth' =&gt; \App\Http\Middleware\Authenticate::class,
          'auth.basic' =&gt; \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
          'bindings' =&gt; \Illuminate\Routing\Middleware\SubstituteBindings::class,
          'cache.headers' =&gt; \Illuminate\Http\Middleware\SetCacheHeaders::class,
          'can' =&gt; \Illuminate\Auth\Middleware\Authorize::class,
          'guest' =&gt; \App\Http\Middleware\RedirectIfAuthenticated::class,
          'password.confirm' =&gt; \Illuminate\Auth\Middleware\RequirePassword::class,
          'signed' =&gt; \Illuminate\Routing\Middleware\ValidateSignature::class,
          'throttle' =&gt; \Illuminate\Routing\Middleware\ThrottleRequests::class,
          'verified' =&gt; \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
      ];
  }
  
  </code></pre>