Skip to content

Commit

Permalink
Set content type header for responses from Leptos so Firefox will be …
Browse files Browse the repository at this point in the history
…happy, and because it's best practice
  • Loading branch information
benwis committed Sep 29, 2023
1 parent 181bcad commit 24f4fb1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion integrations/axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,13 @@ async fn generate_response(
if let Some(status) = res_options.status {
*res.status_mut() = status
}
// Set the Content Type headers on all responses. This makes Firefox show the page source
// without complaining
let headers = res.headers_mut();
headers.insert(http::header::CONTENT_TYPE,HeaderValue::from_str("text/html; charset=utf-8").unwrap(),
);
let mut res_headers = res_options.headers.clone();
res.headers_mut().extend(res_headers.drain());
headers.extend(res_headers.drain());

res
}
Expand Down

0 comments on commit 24f4fb1

Please sign in to comment.