Routes in web.php don't work if its the top level

I am using filamentphp with multi tenancy. I am currently trying to install clockwork but it I cannot access the /clockwork uri. Anyways. I tracked down the problem to all urls which are for example localhost/test or localhost/example. Everything such as /localhost/test/test or localhost/foo/bar works. Is this a known thing? Any way to bypass it? My localhost/test route does show up on php artisan route:list:
GET|HEAD / .................................................................................................................................................. filament.app.tenant › Filament\Http › RedirectToTenantController
GET|HEAD admin ...................................................................................................................................... filament.admin.pages.admin-dashboard › App\Filament\Pages\AdminDashboard
... much /admin stuff
GET|HEAD admin/users/{record}/edit .................................................................................................. filament.admin.resources.users.edit › App\Filament\Resources\UserResource\Pages\EditUser
... other stuff ....
ANY laravel/login ....................................................................................................................................................... login › Illuminate\Routing › RedirectController
... livewire/ stuff...
GET|HEAD test ................................................................................................................................................................................................................
GET|HEAD {tenant} .................................................................................................................................................. filament.app.pages.dashboard › Filament\Pages › Dashboard
... {tenant}/xxx stuff
GET|HEAD / .................................................................................................................................................. filament.app.tenant › Filament\Http › RedirectToTenantController
GET|HEAD admin ...................................................................................................................................... filament.admin.pages.admin-dashboard › App\Filament\Pages\AdminDashboard
... much /admin stuff
GET|HEAD admin/users/{record}/edit .................................................................................................. filament.admin.resources.users.edit › App\Filament\Resources\UserResource\Pages\EditUser
... other stuff ....
ANY laravel/login ....................................................................................................................................................... login › Illuminate\Routing › RedirectController
... livewire/ stuff...
GET|HEAD test ................................................................................................................................................................................................................
GET|HEAD {tenant} .................................................................................................................................................. filament.app.pages.dashboard › Filament\Pages › Dashboard
... {tenant}/xxx stuff
10 Replies
skyracer2012
skyracer20123mo ago
With "don't work" I mean it gets a 404 error.
Tieme
Tieme3mo ago
What are you panel paths look like?
skyracer2012
skyracer20123mo ago
I have one /admin panel which is not multi tenant and one 'app' which path is:
return $panel
->id('app')
->path('')
->tenant(Project::class)
return $panel
->id('app')
->path('')
->tenant(Project::class)
So the path is ''. That is probably the issue but the routes that dont work are above the 'app' route in the route:list command.
Dennis Koch
Dennis Koch3mo ago
It’s because everything is treated as the tenant.
skyracer2012
skyracer20123mo ago
As far as I know in laravel if you have routes before a catch-all route, it should work. I however didnt find where filament registers its routes so it must be somewhere before the web.php registration.
Dennis Koch
Dennis Koch3mo ago
Good question. From what it looks like it should be after your rout (if the order of the route:list command is correct)
skyracer2012
skyracer20123mo ago
I don't know how route:list actually works (maybe its sorted alphabetically). It will have to see where filament hooks in to define its routes. Maybe someone knows where it does that so I would have to give the web.php priority. My providers array in app.php does have the filament routes at the very end:
'providers' => ServiceProvider::defaultProviders()->merge([
/*
* Package Service Providers...
*/
//\Clockwork\Support\Laravel\ClockworkServiceProvider::class,

/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\Filament\AdminPanelProvider::class,
App\Providers\Filament\AppPanelProvider::class,
]
'providers' => ServiceProvider::defaultProviders()->merge([
/*
* Package Service Providers...
*/
//\Clockwork\Support\Laravel\ClockworkServiceProvider::class,

/*
* Application Service Providers...
*/
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\Filament\AdminPanelProvider::class,
App\Providers\Filament\AppPanelProvider::class,
]
Dennis Koch
Dennis Koch3mo ago
Then I guess it should register after all those. Hm, weird. Is it really the tenant route that captures your other routes?
skyracer2012
skyracer20123mo ago
Yes I think so, commenting out the App\Providers\Filament\AppPanelProvider::class, solves the issue and that is where I have my tenant route with path being ''
skyracer2012
skyracer20123mo ago
Confirmed, that it is the tenant route
No description