Laravel

Laravel 5.7 Route [login] not defined

Since Laravel comes with Frontend Scaffolding and supports Vue within the box, therefore I decided to test Laravel 5.7 + Vue app running in same project.

I personally like keeping API/Micro service and App as two separate projects. But in certain situations using Laravel+Vue app in same project could be helpful.

While I was testing  API+Laravel Passport & Vue app, I  encountered an error “Route [login] not defined” when hitting any auth:api guarded endpoint without passing valid Bearer token.

Laravel introduced Authenticate middleware in version 5.7, that redirectes any unauthenticated request to login route by default.

Since I am using Laravel Passport, there I didn’t activated Auth::routes() in application, and for that obvious reason my app is missing web auth routes.

Authenticate middleware default behavior redirects the unauthenticated request to no existing /login route.

Requesting api auth guarded endpoint without valid token, throws InvalidArgumentException.

Middleware:

This error can be resolve by just commenting out.

// return route('login');

Author: Danyal
I'm skilled programmer with expertise in Vue.js/Nux.js for front-end development and PHP Laravel for back-end development. I excel in building APIs and services, and also have experience in web server setup & maintenance. My versatile skill set allows you to develop and maintain web applications effectively, from the user interface to the server-side functionality. I love coding with never ending learning attitude, thanks for visiting danya.dk