Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion docs/articles/migrate-to-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ step; see [Version compatibility](version-compatibility.md) for that.
| [Registration](#register-the-toolkit-and-select-the-htmx-version) | Call `AddHtmxToolkit()` and select the HTMX version; HTMX 2.x is the default | **Silent** |
| [Global configuration](#move-global-configuration-to-code) | `<htmx-config>` attributes move to `AddHtmxToolkit()` | **Silent** |
| [Antiforgery](#antiforgery-metadata-is-on-by-default) | Metadata on by default, moved out of `htmx.config`; token sent to own origin only | **Silent** |
| [Toolkit script](#load-the-toolkit-script-as-a-static-asset) | Inline script helpers and `MapHtmxAntiforgeryScript` replaced by a static web asset | Build |
| [Toolkit script](#load-the-toolkit-script-as-a-static-asset) | Inline script helpers and `MapHtmxAntiforgeryScript` replaced by a static web asset | Build, **silent** |
| [URL Tag Helper](#rename-the-url-tag-helper-attributes) | `hx-*` URL attributes become `asp-*`; `hx-host` and `hx-protocol` are removed | **Silent** |
| [Requests](#update-request-handling) | `IsHtmxRequest()` is `false` for history restoration; `Boosted` filter renamed | Build, **silent** |
| [Action result wrappers](#configure-responses-through-responsehtmx) | `IActionResult.Htmx(...)` removed | Build |
Expand Down Expand Up @@ -208,6 +208,11 @@ In 2.0 it also sends `HX-Request-Type` for HTMX 1.9.x and 2.x, replays events wh
and provides the `ramstack-swap` extension. See [What the Toolkit script does](antiforgery.md#what-the-toolkit-script-does)
and [Static assets and deployment](static-assets.md).

> [!WARNING]
> The script also sends `HX-Request-Type` to other origins. If such an origin lists its allowed request headers explicitly,
> add `HX-Request-Type` to its `Access-Control-Allow-Headers`. Otherwise, the browser blocks the request at the preflight
> and HTMX raises `htmx:sendError`.

## Rename the URL Tag Helper attributes

The URL Tag Helper now reads the standard ASP.NET Core `asp-*` routing attributes instead of its own `hx-*` copies.
Expand Down
4 changes: 4 additions & 0 deletions docs/articles/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,7 @@ Configure application options at startup. Do not change these options while hand
Client settings such as `SelfRequestsOnly`, `Mode`, `WithCredentials`, and per-request credentials
do not configure server CORS. Check the browser CORS error, ASP.NET Core CORS policy,
allowed origins, cookies, and credential rules together.

The policy must allow every header that the request sends. With HTMX 1.9.x and 2.x, the Toolkit script adds
`HX-Request-Type` to the headers that HTMX sends, so include it in an explicit list of allowed headers.
Otherwise, the browser blocks the request at the preflight and HTMX raises `htmx:sendError`.
Loading