filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
18.71k stars 2.91k forks source link

artisan optimze fails if multiple domain is configured #11837

Closed declum closed 6 months ago

declum commented 7 months ago

Package

filament/filament

Package Version

v3.2

Laravel Version

v11

Livewire Version

No response

PHP Version

PHP 8.3

Problem description

If we configure the panel to use multiple domain, php artisan optimize fails

Unable to prepare route [admin/login] for serialization. Another route has already been assigned name [filament.admin.auth.login].

Expected behavior

We should be allowed to use multiple domains.

Steps to reproduce

  1. git clone https://github.com/declum/example-repo
  2. cp .env.example .env
  3. php artisan migrate --seed
  4. I have added two domains in Admin panel provider
  5. php artisan optimze

Reproduction repository

https://github.com/declum/example-repo

Relevant log output

No response

faizananwerali commented 7 months ago

I have noticed that too

dododedodonl commented 7 months ago

We've encountered this problem too. It is caused by how multi domain routes are registered in Laravel.

https://github.com/filamentphp/filament/blob/a8cc2229bdc8d39430b14a5ef2dc987170ae38af/packages/panels/routes/web.php#L24

The same route name gets registered for each domain. Changing this to eg. only name the first domain's route, will cause people to be redirected from one domain to the first domain when a route is retrieved.

danharrin commented 7 months ago

Is it possible to pass multiple domains into Route::domain()?

dododedodonl commented 7 months ago

Route::domain() only accepts a string according to its definition: @method \Illuminate\Routing\RouteRegistrar domain(string $value)

declum commented 7 months ago

->name("{$panelId}.")

Can we prefix the domain name to the route name just like the panelId?

Because, without optimize, if I try access the panel domain-1 panel, it will redirect to domain-2's login page (bcz domain-2 is the last in the list)