Route [login] not defined.Route [login] not defined.
To check either request includes token or not make your own middleware.
php artisan make:middleware CheckApiToken
public function handle($request, Closure $next)
{
if(!empty(trim($request->input('api_token')))){
$is_exists = User::where('id' , Auth::guard('api')->id())->exists();
if($is_exists){
return $next($request);
}
}
return response()->json('Invalid Token', 401);
}You're trying to redirect to a named route whose name is login, but you have
no routes with that name:
Route::post('login', [ 'as' => 'login', 'uses' => 'LoginController@do']);
The 'as' portion of the second parameter defines the name of the route. The
first string parameter defines its route.Use Postman and set the Header `Accept: application/json` otherwise Laravel
Passport would never know it's an API client and thus redirect to a /login
page for the web.
Also in PHP:
- error text encode php json
- check if array is duplicate and get the latest values php
- echo php dropdown from db and save it in a db
- SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
- email configuration for gmail in laravel
- download laravel composer
- DependencyResolver/RuleSet.php on line 84
- codeigniter get num_rows
- What is a Regular Expression in php
- base64 file php
- display time php
- change format date usa month text php
- App\\Http\\Controllers\\DB' not found
- Undefined variable: subcopy laravel mail
- cache issue laravel
- 0 == "string" php
- export html table data to excel in php
- SET CURRENT DATE TIME IN PHP'
- create user laravel seeder
- PHP debug console print
- api newslater with php
- codeigniter delete record by id
- add zeros in front of number php
- difference entre deux date php