Skip to content

Respect htmx 4's HX-Request-Type: full header - #948

Open
scriptogre wants to merge 2 commits into
AnswerDotAI:mainfrom
scriptogre:fix/htmx4-full-request
Open

scriptogre wants to merge 2 commits into
AnswerDotAI:mainfrom
scriptogre:fix/htmx4-full-request

Conversation

@scriptogre

@scriptogre scriptogre commented Oct 29, 2026 •

Copy link
Copy Markdown

Problem

htmx 4 sends HX-Request-Type: full when hx-target is <body>, or when hx-select is used.

Otherwise, it sends HX-Request-Type: partial.

hx-boost makes an htmx request with an implicit hx-target="body", and thus it sends HX-Request-Type: full.

FastHTML sees HX-Request and treats this as a fragment request. It renders <head> children directly alongside body content:

<title>Settings</title>
<link rel="stylesheet" href="/settings.css">
<main>...</main>

Instead of placing them inside <head> in a complete <html> document:

<html>
 <head>
   <title>Settings</title>
   <link rel="stylesheet" href="/settings.css">
 </head>
 <body>
   <main>...</main>
 </body>
</html>

Fix

Render the full <html> when HX-Request-Type: full header is present.

Also add HX-Request-Type to Vary so caches separate full-page and fragment responses.

@scriptogre scriptogre changed the title Handle htmx 4 full-page requests Respect htmx 4's HX-Request-Type: full header Oct 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant