1 | initial version |
To redirect to the '/dashboard' route in a Laravel Sanctum API, follow these steps:
return redirect('/dashboard');
Route::get('/dashboard', 'DashboardController@index')->middleware('auth:sanctum');
Note: The 'auth:sanctum' middleware is used to ensure that only authenticated users can access the '/dashboard' route.
public function index()
{
return view('dashboard');
}
That's it. Now, when a user successfully logs in, they will be redirected to the '/dashboard' route and see the corresponding dashboard view.