Skip to content

Commit

Permalink
feat: detect htmx requests
Browse files Browse the repository at this point in the history
  • Loading branch information
gebeer committed Mar 15, 2024
1 parent 25349da commit 93a6181
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion RockFrontend.module.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ protected function ajaxAddEndpoints(): void
// make htmx endpoints only available via ajax
// superusers are allowed to access them directly (for debugging)
$sudo = $this->wire->user->isSuperuser();
$ajax = $this->wire->config->ajax;
$isHtmx = isset($_SERVER['HTTP_HX_REQUEST']) && $_SERVER['HTTP_HX_REQUEST'];
$ajax = $this->wire->config->ajax || $isHtmx;

if (!$ajax and $sudo) return $this->ajaxDebug($endpoint);
else return $this->ajaxPublic($endpoint);
Expand Down

0 comments on commit 93a6181

Please sign in to comment.