Laravel multitenant how to use api routes for tenant
I have a multitenant laravel web app, in which I have 2 panels, central panel and tenant panel. I am developing it and the idea is for a central panel to manage each building. And each tenant has its own modules that it manages. I have successfully created the two panels. But I'm a little stuck at this point, I want to access tenant routes, let's say with postman, in the same way as I access routes that can be in a simple laravel application (api.php), I don't know how to do this. Can someone help me with this?
I want to make this couse when i try this http://foo.localhost:8000/login on the postman i get "message": "CSRF token mismatch.",
This is the web.php routes
Route::redirect('/', 'login');
Auth::routes();
/**
* Route group middleware
*
*/
Route::group(['middleware' => ['auth']], function () {
// DASHBOARD
Route::get('/dashboard', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
// USERS MANAGEMENTS
Route::resource('roles', RoleController::class);
Route::resource('users', UserController::class);
Route::resource('products', ProductController::class);
});
and this is tenant.php
Route::middleware([
'web',
InitializeTenancyByDomain::class,
PreventAccessFromCentralDomains::class,
])->group(function () {
// Route::get('/', function () {
// return view('auth.login');
// });
Route::redirect('/', 'login');
Auth::routes();
Route::group(['middleware' => ['auth']], function() {
// DASHBOARD
Route::get('/dashboard', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
// USERS MANAGEMENTS
Route::resource('roles', RoleController::class);
Route::resource('users', UserController::class);
// PRODUCTS MANAGEMENTS
Route::resource('products', ProductController::class);
...
});
});
NOTE: I have installed tenancyforlaravel to make the tenants
when i do php artisan route:cache i get this error ` LogicException
Unable to prepare route [login] for serialization. Another route has already been assigned name [login].
at \vendor\laravel\framework\src\Illuminate\Routing\AbstractRouteCollection.php:247`
How can i fix this problem? also i want the tenant route to make as api route, and to make call like thisfoo.localhost:8000/api/v1/login
Please or to participate in this conversation.