fix: response redirect of non hx req

This commit is contained in:
Per Stark
2025-05-09 12:22:15 +02:00
parent 336c7d33f1
commit 1624c08397
@@ -1,7 +1,7 @@
use axum::{ use axum::{
extract::State, extract::State,
http::{HeaderName, StatusCode}, http::{HeaderName, StatusCode},
response::{Html, IntoResponse, Response}, response::{Html, IntoResponse, Redirect, Response},
Extension, Extension,
}; };
use axum_htmx::{HxRequest, HX_TRIGGER}; use axum_htmx::{HxRequest, HX_TRIGGER};
@@ -185,7 +185,11 @@ where
} }
} }
TemplateKind::Redirect(path) => { TemplateKind::Redirect(path) => {
(StatusCode::OK, [(axum_htmx::HX_REDIRECT, path.clone())], "").into_response() if is_htmx {
(StatusCode::OK, [(axum_htmx::HX_REDIRECT, path)], "").into_response()
} else {
Redirect::to(&path).into_response()
}
} }
} }
} else { } else {