We’re using Laravel Socialite with a self-hosted GitLab instance to authenticate users for an internal tool.
Every time the session times out, the OAuth flow redirects the user back to the default dashboard, regardless of what URL the user originally requested.
However, Laravel provides a
url.intended session key with the original URL; here’s how I used it, with a fallback to the dashboard URL:
return redirect()->to( session()->get('url.intended', route('dashboard') );