rob_utopano's avatar

Laravel Passport | Login/Register redirects to welcome page

Hey guys,

I followed this tutorial (https://tutsforweb.com/laravel-passport-create-rest-api-with-authentication/#Install_Package) to getting Passport in my laravel project started.

But when I try to connect to these endpoint via Insomnia (insomnia.rest) I will be redirected to the welcome page.

Is there anything I can do to fix this issue?

Thanks to everyone who can help!

Best regards,

Robert

0 likes
7 replies
aliya's avatar

Which version of laravel you use????

ejdelmonico's avatar

Just add public $redirectTo = '/' in the appropriate controller. You can put whatever route you want by overriding $redirectTo.

rob_utopano's avatar

@EJDELMONICO - regarding to my issue/question, this is not really the answer I need, cause I want to disable this behavior because it makes my login or registration impossible.

rob_utopano's avatar

@TY - Of course, but not if I register a new user via API / REST-Interface with Laravel Passport. Laravel Passport should response a token, for authentication against the application.

rob_utopano's avatar
rob_utopano
OP
Best Answer
Level 2

I found the solution:

It was my failure, the use of use Laravel\Passport\HasApiTokens; inside the user model was false. It must be under the use of use Illuminate\Foundation\Auth\User as Authenticatable;

after fixing this, everything worked fine!

Thanks for everyone who tried to help me!

Please or to participate in this conversation.