I wrote the method in the login controller:
protected function redirectTo()
{
return URL::previous();
}
but this method can only jump to login pages accessed through web;
if you use ajax to access the login page, jump to the home page after login;
write breakpoints in the method:
protected function redirectTo()
{
dd(\request()->headers->get("referer"));
}
whether accessed through ajax or web, http://laravel.demo.com/login
Why does it return the url, of the landing page instead of the url? of the previous page?
the referer address is also included in the header of the request for ajax to access the login page. Why is the jump result different when you use ajax and web to access the page?