1

Just going to preface this question by saying that I'm diving back into Laravel after a while of not using it, it appears there are a lot of changes, and the current project in question is using A LOT of the baked in "Laravel Ecosystem"... so I could be missing some context here.

The issue : After upgrading from Laravel 5.6 to 5.7, auth-guarded API routes are busting because of session expiry, even immediately after logging in (prompting logout).

The configuration :

/config/auth.php

'guards' => ['api' => ['driver' => 'spark']]

/routes/api.php

Route::group([
    'middleware' => 'auth:api'
], function () {
    // Routes in here are busting
}

/app/Providers/SparkServiceProvider.php

protected $usesApi = true; // yup

Additional info :

  • The site uses the Socialite plugin for managing user authentication
  • There are indeed spark_token's in the request
  • Vue client making the calls, getting status 401 Unauthorized on the next page load after successfully authenticating via login form
  • It was working perfectly fine before upgrading from Laravel 5.6 to 5.7

Any ideas? I've poured through the Laravel 5.7 release notes / upgrade guide, not finding any relevant info.

coleman-benjamin
  • 921
  • 1
  • 15
  • 29

1 Answers1

0

Found a solution that worked for me:

Add to app/Http/Middleware/EncryptCookies.php

    /**
     * Indicates if cookies should be serialized.
     * @var bool
     */
    protected static $serialize = false;

Then clear cookies from your browser, and retry logging in.

LeigerGaming
  • 504
  • 1
  • 4
  • 17