Skip to content

Instantly share code, notes, and snippets.

@Braunson
Created January 6, 2022 21:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Braunson/93e67cb9592127d835f0da9abb4fdc8c to your computer and use it in GitHub Desktop.
Save Braunson/93e67cb9592127d835f0da9abb4fdc8c to your computer and use it in GitHub Desktop.
Detect if a request is from Livewire or not, useful when you have middleware that needs to ignore Livewire requests. Drop this in the boot method.
<?php
// Detect requests from Livewire
Request::macro('isFromLivewire', function() {
return $this->headers->has('x-livewire');
});
@danjdewhurst
Copy link

Very useful, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment