Check if Livewire request came from Filament
I have the following macro in my AdminPanelProvider to check if requests came from Filament, this is inspired by
Request::inertia()
provided by Inertia.js:
This works for the default views across the panel, however the livewire.update
route ofcourse doesn't fall under this.
Is there a recommended approach to check if a Livewire request came from Filament? I don't feel like adding livewire.* is specific enough, since other panels or other Livewire components outside Filament would give false positives.
I've looked into adding (persistent) middlewares to my panel providing adding a x-filament header myself, but these middlewares seem to run after the Livewire request.
Thanks in advance!1 Reply
Actually, I'm using tenancy so got the idea to check if the current tenant could be retrieved during the Livewire request.
This made me test out the panel helpers and this seems to work perfectly for both views and livewire requests:
This approach also doesn't rely on the filament.admin.* routing check π
Made it also more generic for checking the other panels while at it I guess