Level 65
Don't you want to redirect back to auth/facebook/callback instead of auth/facebook since that redirects back to Facebook?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Im using Valet, when accessing "http://proj.test/auth/facebook" we are redirected to "http://proj.test/auth/facebook?code=B...". But it appears an error:
Page is not working, proj.test redirect too many times. ERR_TOO_MANY_REDIRECTS.
Do you know how to fix the error?
Routes:
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::get('auth/facebook', 'Auth\RegisterController@redirectToProvider');
Route::get('auth/facebook/callback','Auth\RegisterController@handleProviderCallback');
Services.php
'facebook' => [
'client_id' => '2...',
'client_secret' => 'a...',
'redirect' => 'http://proj.test/auth/facebook'
]
RegisterController:
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
use Socialite;
class RegisterController extends Controller
{
use RegistersUsers;
protected $redirectTo = '/home';
public function __construct()
{
$this->middleware('guest');
}
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
public function redirectToProvider()
{
return Socialite::driver('facebook')->redirect();
}
public function handleProviderCallback()
{
$user = Socialite::driver('facebook')->user();
return $user->getEmail();
// $user->token;
}
}
Don't you want to redirect back to auth/facebook/callback instead of auth/facebook since that redirects back to Facebook?
Please or to participate in this conversation.