laravel redirect to wrong url after auth success
-
guys I need a help, I deployed a laravel app inside domain/external folder and in the laravel app index.php i changed the paths to /../external/storage etc.
when I go to the domain it will redirect me to domain/external perfectly but however after I login in the laravel app the Auth module will redirect me to domain/ instead of domain/external
how to fix it,
I already tried this inside authcontroller but won't work
protected function redirectTo()
{
return '/path';
} -
overide login function.
inside login controller (app/Http/Controllers/Auth/LoginController.php)
<?php namespace App\Http\Controllers\Auth; use App\Http\Controllers\Controller; use App\Providers\RouteServiceProvider; use Illuminate\Foundation\Auth\AuthenticatesUsers; use Illuminate\Http\Request; use Auth; class LoginController extends Controller { /* |-------------------------------------------------------------------------- | Login Controller |-------------------------------------------------------------------------- | | This controller handles authenticating users for the application and | redirecting them to your home screen. The controller uses a trait | to conveniently provide its functionality to your applications. | */ use AuthenticatesUsers; /** * Where to redirect users after login. * * @var string */ protected $redirectTo = RouteServiceProvider::HOME; /** * Create a new controller instance. * * @return void */ public function __construct() { $this->middleware('guest')->except('logout'); } /** * Write code on Method * * @return response() */ public function login(Request $request) { $request->validate([ 'email' => 'required', 'password' => 'required', ]); $credentials = $request->only('email', 'password'); if (Auth::attempt($credentials)) { return redirect()->route('home'); } return redirect("login")->withSuccess('Oppes! You have entered invalid credentials'); } }
-
@lkdev bro in my laravel app there is only authController regarding login, is it normal? however I solved the issue, the issue was the subdomain which I was given was inside another subdomain so the laravel app goes crazy, so what I did was created a separate subdomain in a new hosting and tried, and that worked.