My personal site cherry.computer
htmx tailwind axum askama

feat: add HSTS header to responses

I'll bump the max time and get it preloading when I summon the courage.

+11 -3
+1
server/Cargo.toml
··· 15 "compression-full", 16 "fs", 17 "trace", 18 ] } 19 tracing = "0.1.34" 20 tracing-subscriber = "0.3.11"
··· 15 "compression-full", 16 "fs", 17 "trace", 18 + "set-header" 19 ] } 20 tracing = "0.1.34" 21 tracing-subscriber = "0.3.11"
+10 -3
server/src/main.rs
··· 5 use crate::scrobble_monitor::ScrobbleMonitor; 6 7 use axum::{ 8 - http::StatusCode, 9 response::IntoResponse, 10 routing::{get, get_service}, 11 Extension, Router, 12 }; 13 use tower::ServiceBuilder; 14 - use tower_http::{compression::CompressionLayer, services::ServeDir, trace::TraceLayer}; 15 16 #[tokio::main] 17 async fn main() -> anyhow::Result<()> { ··· 26 ServiceBuilder::new() 27 .layer(TraceLayer::new_for_http()) 28 .layer(CompressionLayer::new()) 29 - .layer(Extension(monitor)), 30 ); 31 32 let addr = SocketAddr::from(([0, 0, 0, 0], 8080));
··· 5 use crate::scrobble_monitor::ScrobbleMonitor; 6 7 use axum::{ 8 + http::{HeaderName, HeaderValue, StatusCode}, 9 response::IntoResponse, 10 routing::{get, get_service}, 11 Extension, Router, 12 }; 13 use tower::ServiceBuilder; 14 + use tower_http::{ 15 + compression::CompressionLayer, services::ServeDir, set_header::SetResponseHeaderLayer, 16 + trace::TraceLayer, 17 + }; 18 19 #[tokio::main] 20 async fn main() -> anyhow::Result<()> { ··· 29 ServiceBuilder::new() 30 .layer(TraceLayer::new_for_http()) 31 .layer(CompressionLayer::new()) 32 + .layer(Extension(monitor)) 33 + .layer(SetResponseHeaderLayer::overriding( 34 + HeaderName::from_static("strict-transport-security"), 35 + HeaderValue::from_static("max-age=300; includeSubDomains"), 36 + )), 37 ); 38 39 let addr = SocketAddr::from(([0, 0, 0, 0], 8080));