Open eelco2k opened 2 months ago
nevermind, issue was within another package... fixed will close issue
Actually this still applies when using multiple domains
see example when using php artisan route:list
GET|HEAD localhost/two-factor-authentication ................................ localhost.filament.central-admin.auth.two-factor › Jeffgreco13\FilamentBreezy › TwoFactorPage
GET|HEAD 10.0.0.120/two-factor-authentication .............................. 10.0.0.120.filament.central-admin.auth.two-factor › Jeffgreco13\FilamentBreezy › TwoFactorPage
GET|HEAD central.lan/two-factor-authentication ............................ central.lan.filament.central-admin.auth.two-factor › Jeffgreco13\FilamentBreezy › TwoFactorPage
GET|HEAD admin.lan/two-factor-authentication .......... admin.lan.filament.admin-portal.auth.two-factor › Jeffgreco13\FilamentBreezy › TwoFactorPage
GET|HEAD client.lan/two-factor-authentication ........ client.lan.filament.client-portal.auth.two-factor › Jeffgreco13\FilamentBreezy › TwoFactorPage
so the line with the
->name("{$panelId}.")
should be replaced with:
->name(!empty($domain) ? "{$domain}.{$panelId}." : "{$panelId}.")
furthermore MustTwoFactor.php should be changed as such:
<?php
use Filament\Facades\Filament;
use Illuminate\Support\Facades\Route;
Route::name('')->group(function () {
foreach (Filament::getPanels() as $panel) {
$panelId = $panel->getId();
$domains = $panel->getDomains();
$hasTenancy = $panel->hasTenancy();
foreach ((empty($domains) ? [null] : $domains) as $domain) {
Route::domain($domain)
->middleware($panel->getMiddleware())
->name(!empty($domain) ? "{$domain}.filament.{$panelId}." : "filament.{$panelId}.")
->prefix($panel->getPath())
->group(function () use ($panel, $hasTenancy) {
if ($panel->hasPlugin('filament-breezy')) {
$route = $hasTenancy ? '/{tenant}/two-factor-authentication' : '/two-factor-authentication';
$action = filament('filament-breezy')->getTwoFactorRouteAction();
Route::get($route, $action)->name('auth.two-factor');
}
});
}
}
});
this way you make sure you always prepend the Route::domain() in front of the Route ->name() which makes that specific route always unique per domain.
Error when using multiple domains in a panel:
The fix is that the name of the route should contain the domain suffixed in the route name in web.php. like so:
->name(!empty($domain) ? "{$panelId}.{$domain}." : "{$panelId}.")