F
Filament•9mo ago
Thijmen

Filament on different domains

Is multi panel on different domains only possible on subdomains? Or is there a way to get it to work on different domains?
26 Replies
Dennis Koch
Dennis Koch•9mo ago
Not sure why it should be an issue?
Thijmen
Thijmen•9mo ago
What would be the best way to handle this? With dns on subdomains or a laravel multidomain package?
Dennis Koch
Dennis Koch•9mo ago
Is there a need for a multidomain package? Doesn't Laravel support this out of the box? Can't you just point them to the same server? Or are you talking about multitenancy?
Thijmen
Thijmen•9mo ago
No just multi panel Out of the box the only thing i could find was subdomain
Dennis Koch
Dennis Koch•9mo ago
But why should there be any difference? Should be easy to test via Valet.
Thijmen
Thijmen•9mo ago
Wsl user 🙂 What does the current domain method do on a Panel? Because that only works with subdomains right? And you still have 1 app.
Dennis Koch
Dennis Koch•9mo ago
It does the same as Route::domain() Why should it only work with subdomains?
Thijmen
Thijmen•9mo ago
Not sure. Laravel docs only say something about subdomains. And not sure how you can handle multiple domains and 1 installation.
Dennis Koch
Dennis Koch•9mo ago
It’s not limited to subdomains. I use it with separate domains (not Filament though)
Thijmen
Thijmen•9mo ago
I am just trying this. But how would you go with getting users logged in for all panels? Due too being it different domains you get different cookies so you are not logged in on all panels if you sign in on the main one
Dennis Koch
Dennis Koch•9mo ago
I guess you can’t.
toeknee
toeknee•9mo ago
I ended up doing this with an older multi-tenancy and when changing domains I used JWT's to auto-login the user
Dennis Koch
Dennis Koch•9mo ago
So you had default Laravel Auth + JWT for Fallback when switching?
toeknee
toeknee•9mo ago
Yep!
Dennis Koch
Dennis Koch•9mo ago
Sounds like a smart solution.
toeknee
toeknee•9mo ago
Thank you! It worked well to handle multi-domains with a single login 🙂
Thijmen
Thijmen•9mo ago
What did that JWT package do?
toeknee
toeknee•9mo ago
It adds JSON Web Token support so you can auto-login with a url that includes a valid JWT
Dennis Koch
Dennis Koch•9mo ago
Just wondered where you would store that token. So it only works when redirected from within the app, right?
jaya
jaya•9mo ago
hello Dennis
toeknee
toeknee•9mo ago
I used the JWT package which stores it in the database and it’s time restricted. You can then also choose to limit the usage from within the application too. I didn’t url restrict it as we didn’t need too really and just created a 5minute token that was created in the redirect controller. So we went internally to a controlled which took the redirect uri, generated the token and redirected the user to the new url with the JWT in toe, as such authenticating the user. Similar to how react etc works with JWT’s.
Thijmen
Thijmen•9mo ago
With this you could only have one login page right?
toeknee
toeknee•9mo ago
It wouldn't matter how many you have, you can add JWT support to the routes by default.
Thijmen
Thijmen•9mo ago
If you are logged in on domain1.com and you then visit domain2.com directly will you still be logged in there?
Dennis Koch
Dennis Koch•9mo ago
Nope
toeknee
toeknee•9mo ago
No, you would need to click the link for domain2 from the Panel to handle a redirect for you That's impossible by the browser as it would be a major security hole.