Laravel and Vue - Web / Auth middleware is pushing out my users randomly.

Posted 2 months ago by mmacdonald

My app has two Vue single page "Apps" within it that Laravel redirects to based on the web / auth middleware.

So all routes go through "/" as usual. If the user is authenticated then they're redirected to the interior app, if the aren't then they are redirected to the Welcome app.

The interior app has a Vue router which chooses the components to display.

The problem though is that somehow people are getting pushed out to the Welcome app fairly often. Often you can even just go back to the www.website.com/ base route in your browser and it will take you back to the interior app again, because you weren't really "signed out".

It's as if the app is forgetting my session token or something temporarily and I don't know how to trace what's causing it.

So that's what I'm hoping for here: that someone can "trace" out what the process is for Laravel -> Vue and where the token might be getting "lost".

Here are the two important routes:

//This one has no middleware
Route::get('welcome', 'Auth\[email protected]')->name('login');

AND

//This one is in the web middleware group AND I'm calling the Auth middleware inside the //HomeController
Route::group(['middleware' => 'web'], function(){
    Route::get('/', '[email protected]');
}

//Home Controller
public function __construct()
 {
       $this->middleware('auth');
  }

Anything else you want to see, just let me know. This one is a bit hard to know what I should include, since I don't really know which file might be the source of the problem.

Thanks for your help!

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.