Use subdomain for single route in combination with MultiTenant subdomain

Before using filament in combination with the MultiTenant solution our application was exposed on the domain: dashboard.example.org. Now that we are preparing a launch with MultiTenancy support from Filament we are looking for a way to catch this explicit route and let it forward to the first availble tenant instead of throwing the 404 when trying to retrieve the record. But we are not yet succesfull in doing so, wetried different solutions in terms of: - tenantMiddleware - bootUsing - custom middleware Are there any options we might have missed, or is there something we explicitly need to set in the middleware or other attempted solutions to do this, or is it simply not possible?
6 Replies
toeknee
toekneeβ€’2mo ago
Add this to the web routes.php
use Illuminate\Support\Facades\Route;

Route::domain('dashboard.example.org')->group(function () {
Route::any('{any}', function () {
return redirect()->to('https://newdestination.example.com');
})->where('any', '.*');
});
use Illuminate\Support\Facades\Route;

Route::domain('dashboard.example.org')->group(function () {
Route::any('{any}', function () {
return redirect()->to('https://newdestination.example.com');
})->where('any', '.*');
});
Just fetch the panels in the route::any method and redirect to the desired route.
Mike πŸš€
Mike πŸš€OPβ€’2mo ago
Thanks for the reply, this appears to work for everything except the "/" path. I think this might be related to the filament route being defined earlier (when checked using route:list command)
toeknee
toekneeβ€’2mo ago
It shouldn't be the case if scoping to the domain. you could try:
Route::domain('dashboard.example.org')->group(function () {
Route::any('{any}', function () {
return redirect()->to('https://newdestination.example.com');
})->where('any', '.*');
Route::get('/', function () {
return redirect()->to('https://newdestination.example.com');
})
});
Route::domain('dashboard.example.org')->group(function () {
Route::any('{any}', function () {
return redirect()->to('https://newdestination.example.com');
})->where('any', '.*');
Route::get('/', function () {
return redirect()->to('https://newdestination.example.com');
})
});
Mike πŸš€
Mike πŸš€OPβ€’2mo ago
Unfortunately no luck there, but just tried that when I add a path to my multitenant panel (for the sake of testing a single letter) the route gets hit as expected. Now that I check my original question again I should have mentioned that I use subdomain routing, so this is why I think
toeknee
toekneeβ€’2mo ago
I wouldn't have thoughtso. Do a php artisan route:list
Mike πŸš€
Mike πŸš€OPβ€’2mo ago
When i do that it first lists:
GET|HEAD {tenant}.example.org/
GET|HEAD {tenant}.example.org/
And at the bottom:
ANY dashboard.example.org/{any}
ANY dashboard.example.org/{any}

Did you find this page helpful?