Security

Filtering Middleware

By default, Livewire request inherit the middleware of the page the component was loaded on. If there is middleware you'd like to exclude from subsequent Livewire requests, you can use the filterMiddleware() method like so:

In the following example, we are excluding LogAdminAreaAccessMiddleware from being executed on livewire requests.

public function boot()
{
    // Only exclude LogAdminAreaAccessMiddleware
    Livewire::filterMiddleware(function($middleware) {
        return ! $middleware instanceof LogAdminAreaAccessMiddleware;
    });
}
Using closure middlewares is not supported on Livewire requests (because they have to be serialized), and an error is thrown. If you have any closure middleware in your application, you may consider moving them to a class middleware or use the Livewire::filterMiddleware() to exclude them.
public function boot()
{
    // Exclude all closure middlewares
    Livewire::filterMiddleware(function($middleware) {
        return ! $middleware instanceof Closure;
    });
}