Search code examples
laravel-5laravel-socialite

InvalidStateException in AbstractProvider.php line 199 on production, Laravel 5.2.39


I use Socialite 2.0 and Laravel 5.2.39. The social login on localhost:8000 is working properly but It doesn't work on the production site (example.com).

public function handleProviderCallback($provider) { $social_user = Socialite::driver($provider)->user(); .... }

The exception error when call Socialite::driver($provider)->user() function is:

InvalidStateException in AbstractProvider.php line 199

I tried all solutions people suggested but no luck. Here is some configuration

SESSION_DRIVER=file DOMAIN=example.com URL=http://example.com (used in config/app.php) DOMAIN=mysite.com (used in config/session.php)

Here are the routes:

Route::get('redirect/{provider}', 'Auth\AuthController@redirectToProvider'); Route::get('callback/{provider}', Auth\AuthController@handleProviderCallback');

Thanks for helping!


Solution

  • Finally I found the solution. It's related to Nginx configuration. Use try_files $uri $uri/ /index.php$is_args$args; instead of try_files $uri $uri/ /index.php$query_string; on file /etc/nginx/sites-available/.