Ostap Brehin
Ostap Brehin

Reputation: 3957

How to use auth in api routes

I'm trying to call Auth::user() in my routes/api.php file.

But the Auth::user() returns null.

Meanwhile, as in the routes/web.php file it work.

How to fix it?

I will be grateful...

Upvotes: 2

Views: 1151

Answers (1)

Sohel0415
Sohel0415

Reputation: 9853

Call with guard()

Auth::guard('api')->user();

Upvotes: 3

Related Questions