Documentation typo correction (#3182)

* Documentation update to include the use of hx-headers to prevent CSRF

* Update hx-headers.md

Revised follow review.

* Update docs.md

Typo correction
This commit is contained in:
TGJ Gilmore 2025-02-12 08:41:55 +00:00 committed by GitHub
parent 72b425f5fb
commit 0f9c4202ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1662,7 +1662,7 @@ for exploring this topic.
### CSRF Prevention
The assignment and checking of CSRF tokens are typically backend responsibilities, but `htmx` can support returning the CSRF token automatically with every request using the `hx-headers` attribute. The attribute needs to be added to the element issuing the request or one of its ancestor elements. This makes the `html` and `body` elements effective global vehicles for adding the CSRF token to the `HTTP` request header, as illustarted below.
The assignment and checking of CSRF tokens are typically backend responsibilities, but `htmx` can support returning the CSRF token automatically with every request using the `hx-headers` attribute. The attribute needs to be added to the element issuing the request or one of its ancestor elements. This makes the `html` and `body` elements effective global vehicles for adding the CSRF token to the `HTTP` request header, as illustrated below.
```html
<html lang="en" hx-headers='{"X-CSRF-TOKEN": "CSRF_TOKEN_INSERTED_HERE"}'>