August 2024
Intermediate to advanced
186 pages
4h 3m
English
In some web applications, it’s desirable to add specific HTTP headers to all requests sent from the browser. For example, an authentication token can be passed in a request header named X-Token.
Htmx dispatches the htmx:configRequest event before sending each request. These events bubble up. An event listener can be added to the body element to intercept all of them. That event handler can set HTTP headers by assigning to event.detail.headers[’{header-name}’].
The following HTML demonstrates doing this.

First, we load some CSS and the htmx library. Then we define the window.onload function which is called when the ...
Read now
Unlock full access