feat(not_found): commit HTTP 404 status code during SSR

This commit is contained in:
xfy 2026-07-09 17:33:19 +08:00
parent 1b38162ca4
commit 8cf34769e5

View File

@ -17,6 +17,15 @@ use crate::router::Route;
pub fn NotFound(segments: Vec<String>) -> Element { pub fn NotFound(segments: Vec<String>) -> Element {
let _ = segments; let _ = segments;
// Commit 404 status code during server-side rendering
#[cfg(feature = "server")]
{
dioxus::fullstack::FullstackContext::commit_http_status(
http::StatusCode::NOT_FOUND,
Some("Page Not Found".to_string()),
);
}
rsx! { rsx! {
div { class: "flex flex-col items-center justify-center text-center min-h-[50vh] md:min-h-[55vh] px-6", div { class: "flex flex-col items-center justify-center text-center min-h-[50vh] md:min-h-[55vh] px-6",
// 巨大的装饰性 404作为视觉锚点 // 巨大的装饰性 404作为视觉锚点