Closed jackpit93 closed 4 years ago
Hi there,
Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:
However, this issue will not be locked and everyone is still free to discuss solutions to your problem!
Thanks.
please see this : https://stackoverflow.com/questions/tagged/laravel-sanctum
Most users have the same problem and no one has given the right answer.It is a good idea to provide a solution to this problem instead of sending a duplicate message.
It's hard to provide a solution for your error just by looking your vue component. A lot of things may be going on, like cors, Auth middleware, content negotiation.
About redirection to /home, ensure you're sending proper Accept and ContentType headers (application/json).
About 401, I had a similar issue, but I eventually found out that I wasn't using auth guards in the right way.
"Problem" is in RedirectIfAuthenticated
middleware, which is aliased to guest
. Base LoginController
is protected by guest
middleware, so if you once logged in you will hit this part of code every time you try to log in again:
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
in local work, but production use shared hosting not work, where that's wrong'
{ "message": "Unauthenticated." }
The following updated code inside the RedirectIfAuthenticated
controller works:
if (Auth::guard($guard)->check()) {
if ($request->wantsJson()) {
return response()->json(['result' => 'success'], 200);
}
return redirect(RouteServiceProvider::HOME);
}
Description:
this is my vue login file:
after login request with axios laravel go to home url and i have error in console
I'm sure the password and username are correct. Shouldn't html be returned to me when I use axios.