I have a VueJS route in my SPA application. I would like to apply a Laravel Middleware to a route (the auth middleware, in this case).
Actually, I have try this:
app.js
const router = new VueRouter({
mode: 'history',
routes: [
{
path: '/',
name: 'home',
component: require('./views/Home').default,
},
{
path: '/hello',
name: 'hello',
component: require('./views/Hello').default,
},
],
});
routes/web.php
Route::get('/hello', 'HomeController@home')->middleware('auth');
Route::get('/{any}', 'FrontendController@index')->where('any', '.*');
In this code, I have try to link the auth
middleware to the route /hello
, but it don't work. What is the best way to do that ?
Thanks.
auth:web
middleware. You can tell if you inspectrequest()->user()
inside your controller. – amphetamachine./artisan route:list
. – amphetamachine