I'm working on a project where for each user there will be separate subdomain for example my website name is xyz.com then for user it will be user.xyz.com, for that im trying to do subdomain routing but its not working.
Below are the routes for main domain
Route::get('/', function () {
return redirect('login');
});
Auth::routes();
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Below are routes for subdomain
Route::domain('user.xyz.com')->group(function () {
Route::get('/posts', function () {
return 'Second subdomain landing page';
});
});
Any expert please look into this. Suggestions are welcome.