I am trying to access an authenticated user but it is returning an empty object.
The auth()->user() returns an empty object
I have tried someone's suggestion of creating the API route in the web.php file then use web auth middleware but when I send a request to that route, instead of it saving the data into the database, it returns the login page. How do I go about this?
It is not an API. I receive data through post, and I have to save that data in the database. Now I am trying to get the logged in User through auth()->user() but that is returning null. The data comes through a request
But even with web.php, when I try posting data, I get page expired error when I try to add the route in the exempted routes in VerifyAuthToken middleware, I again can't access the auth()->user() object.
Well, let's say you are doing payment API integration, where after successful payment, the API sends data to your callback URL. Now of course you what to save that data under the user who did that transaction. So how do you get the user_id if the response data is sent through an API route? That's the situation I am in