I try to create a basic spa, but I want to use the basic authentication of laravel and not create a login system in vue, after logging in, it redirects me to the route /admin where I want it to be the entry point of my spa, try with this configuration and it shows nothing.

web.php -> routing

Route::get('/admin/{any}',function(){
    return view('app');
})->where('any','.*')->name('admin')->middleware('auth');

Route::get('/admin',function(){
    return view('app');
})->name('admin')->middleware('auth');


Route::get('/', 'Auth\[email protected]')->name('showLoginForm');
Route::post('login', 'Auth\[email protected]')->name('login');
Route::post('logout', 'Auth\[email protected]')->name('logout');

in my app view, I have the app file compiled with the following routes

const routes = [

    {
        path: '/admin',
        component: () => import(/* webpackChunkName: "routes" */`~/Pages/Layouts/Admin`), 
        meta: { requiresAuth: true },
        children: [
            {
                path : '/', name : 'Home',
                component: () => import(/* webpackChunkName: "routes" */`~/Pages/Admin/Home`),
                meta: { },
            },
            { 
                path : 'usuarios',
                component: () => import(/* webpackChunkName: "routes" */`~/Pages/Admin/Usuarios/Index`),
                meta: { },
                children : [
                    {

                    }
                ]
            },

            { 
                path: '403',
                name:'403', 
                component: () => import(/* webpackChunkName: "routes" */`~/Pages/Errors/403`)
            },
        ]
    },

]

export default routes;

the routes I'm looking for is misite.com/admin/users for example, of course the path users would be a route of my vueRouter

1 Answers

0
Thamer belfkih On

If you are going to redirect your users after login with auth laravel system to /admin path, just go to App\Http\Controllers\Auth\LoginController and edit the $redirectTo attribute like this:

$redirectTo = '/admin'

as mentioned in laravel doc :

When a user is successfully authenticated, they will be redirected to the /home URI. You can customize the post-authentication redirect location by defining a redirectTo property on the LoginController, RegisterController, ResetPasswordController, and VerificationController.

for more information please check the doc Path Customization Laravel after login