FilamentF
Filament17mo ago
Laurens

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:

 Request::macro('adminPanel', fn () => Request::routeIs('filament.admin.*'));


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!
Was this page helpful?