I am new to do laravel and Vue js web application. in my laravel project already works with laravel default authentication. When I use Vue js for frontend, I used laravel sanctum for api authentication. This is working for Vue js frontend but my default laravel authentication for backend admin login is not working when I add
SESSION_DOMAIN=localhost
SANCTUM_STATEFUL_DOMAINS=localhost in .env file.
When I removed those two lines, sanctum is not working but default authentication was working again. how to fix that problem. I want to work with my laravel backend admin panel login with laravel default authentication and want to work with laravel sanctum for vue js frontend user login. Could you please help me? Thanks.
.env
SESSION_DOMAIN=localhost
SANCTUM_STATEFUL_DOMAINS=localhost
I used the same domain for backend and frontend. For example,
For admin login
http://127.0.0.1:8000/admin/login
For frontend login
http://127.0.0.1:8000/login
in web.php
Route::namespace('Admin')->prefix('admin')->group(function() {
Route::namespace('Auth')->group(function() {
// Authentication Routes
Route::get('/login', 'LoginController@showLoginForm')->name('admin.login');
Route::post('/login', 'LoginController@login');
Route::post('logout', 'LoginController@logout')->name('admin.logout');
});
});
in api.php
Route::post('/login', 'Auth\LoginController@userLogin');
admin login
when login, it shows the error after adding SESSION_DOMAIN=localhost, SANCTUM_STATEFUL_DOMAINS=localhost in .env