I don't know how to send header again as part of redirect handling #3214
-
I have a request
that responds with a 302:
This is all fine. But, the HTMX follows on this redirect without letting me send again the header. In other words, htmx adds its own
How can I add my custom headers as part of the 302 handling, just as I can do in the normal htmx initial request? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I have read this part from the page https://htmx.org/docs/#response-headers:
So it's more clear (if I understood it correctly) that there is an explicit design choice here, but I am asking myself how can then htmx add the HX-* requests. Just wanted to make sure I am not missing something because it... feels like... it should be possible. |
Beta Was this translation helpful? Give feedback.
Not really! At least, not our choice ; the browser simply doesn't let us know about this standard redirection happening, so just as you don't receive a
htmx:configRequest
event for the "new" request, htmx itself cannot either catch it. The browser will follow the redirection and eventually pass its response to htmx, which won't even know about the first response that was redirected.So, to answer your question in that part, htmx doesn't add its
hx-*
headers to the redirected request, the browser is doing that automatically.As for your issue itself, I just tried with a local setup, if I set a custom header in a
htmx:configRequest
event listener, t…