Cannot use HX-* response headers with hx-boost?
Closed this issue · 3 comments
I feel like I must be missing something, but I cannot for the life of me get an Hx-Trigger
header on a response to an Hx-Boost
request to do anything.
I have CORS set up, even though I have everything going to the same host (localhost
), but Firefox isn't making any CORS OPTIONS
preflight requests for hx-boost when my form is submitted (which I suppose makes sense, given that this is a "simple" request).
I even tried putting wide-open Access-Control-
headers on the response coming back from the hx-boost
response, to no avail:
Note the presence of the Hx-Trigger
header, and yet when I step through the debugger through handleAjaxResponse
, into hasHeader
, the Hx-Trigger
header is nowhere to be found:
What am I missing? How do I get HX-Trigger
to work on a boosted request when there is no preflight OPTIONS
request, and HTMX
can't retrieve the same-origin headers?
I figured it out! I was setting hx-trigger on a 302 redirect response, but the page being redirected to did not itself set hx-trigger. XHR transparently follows redirects, and so the client JavaScript code only had access to the final headers from the destination page.
Is this maybe worth a mention in the docs? Just a short sentence or a callout or something.
Docs have now been updated to highlight this issue so can probably close this now