Filament::getTenant() is null on AJAX calls
When things are updated like table poll requests, it uses a middleware I am using to sync the spatie permission team id with the filament team. This works well on page requests but on AJAX requests Filament::getTenant() is null. Any idea how I can fix that?
Solution:Jump to solution
fixed it by adding
IdentifyTenant::class,
SyncSpatiePermissionsWithFilament::class,
to the end of the ->middleware() method of the panel...
2 Replies
I can tell that it has something to do with the order in which the middlewares are executed. Looks like IdentifyTenant is executed after other tenant middlewares and this is why it fails.
For web request routes it does this so it makes sure the tenant is set before:
public function getTenantMiddleware(): array
{
return [
IdentifyTenant::class,
...$this->tenantMiddleware,
];
}
Solution
fixed it by adding
IdentifyTenant::class,
SyncSpatiePermissionsWithFilament::class,
to the end of the ->middleware() method of the panel