Panel with ->domains option

I'm trying to make my Panel work for two specific domains using the ->domains() option. With php artisan optimize I get The current domain is not set, but multiple domains are registered for the panel. Please use [Filament::currentDomain('example.com')] to set the current domain to ensure that panel URLs are generated correctly. I've tried defining Filament::currentDomain('example.com') in various places but it didn't work out. Can someone help me out?
Solution:
Okay I think I found a workaround with: ```php class GlobalPanelProvider extends PanelProvider {...
Jump to solution
2 Replies
Solution
mmoollllee
mmoollllee2w ago
Okay I think I found a workaround with:
class GlobalPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
$domains = ['maindomain.com', 'otherdomain.com'];

if (app()->runningInConsole() && ! empty($domains)) {
Filament::currentDomain($domains[0]);
}

return $panel
->default()
->id('global')
->path('/')
->domains($domains)
class GlobalPanelProvider extends PanelProvider
{
public function panel(Panel $panel): Panel
{
$domains = ['maindomain.com', 'otherdomain.com'];

if (app()->runningInConsole() && ! empty($domains)) {
Filament::currentDomain($domains[0]);
}

return $panel
->default()
->id('global')
->path('/')
->domains($domains)
Dennis Koch
Dennis Koch2w ago
I guess the best way would be to identify the domain inside a middlewar.

Did you find this page helpful?