The "HX-Request" header is automatically included for every request triggered by HTMX. You can just check that to know if you should respond with a fragment or the full page.
If you use HX-Request header to overload routes with both normal browser and htmx requests, remember to add `Vary: HX-Request` as well, otherwise the browser may use cached htmx requests when you reload the page.