REST API route in Laravel redirect to login page

I have built the REST api for my Vue.js application and I have used the Laravel Passport authentication to authenticate the API end point
I have the following code snippet in my routes/api.php file. It basically return array of post when I call the URL http://localhost/api/posts provides that you have correct authentication. I am calling auth:api as a middleware in this route

If you are not familiar with API authentication you can refer this article in this website

Route::middleware(‘auth:api’)->get(‘/posts’, function (Request $request) {

return Post::all();
});

Now I am going to test this API end point uing Postman software

First you need to pass the username and the password to get the access token

Now you can see the acess token. So the provides authentication is correct and I need to pass the token to server to access the API end point now.

Lets see how we can do it in Postman.
To access the url http://localhost:8000/api/posts you need to passs token as well as content-type parameter. Otherwise page will be return to login pages again and show the output in Postman

So this