@@ -19,21 +19,17 @@ fn frontend_dir() -> PathBuf {
1919/// Serve static files with SPA fallback and proper cache headers.
2020pub async fn static_handler ( req : Request < Body > ) -> Response {
2121 let frontend_dir = frontend_dir ( ) ;
22- let path = req. uri ( ) . path ( ) . to_owned ( ) ;
23- let is_root = path == "/" ;
2422
25- let has_extension = path
23+ let has_extension = req
24+ . uri ( )
25+ . path ( )
2626 . rsplit ( '/' )
2727 . next ( )
2828 . map ( |segment| segment. contains ( '.' ) )
2929 . unwrap_or ( false ) ;
3030
3131 // Serve static files if they have an extension, otherwise fallback to the index.html file
32- let result = if is_root {
33- ServeFile :: new ( frontend_dir. join ( "index.html" ) )
34- . oneshot ( req)
35- . await
36- } else if has_extension {
32+ let result = if has_extension {
3733 ServeDir :: new ( frontend_dir. clone ( ) ) . oneshot ( req) . await
3834 } else {
3935 ServeDir :: new ( frontend_dir. clone ( ) )
@@ -50,7 +46,7 @@ pub async fn static_handler(req: Request<Body>) -> Response {
5046 . map ( |ct| ct. contains ( "text/html" ) )
5147 . unwrap_or ( false ) ;
5248 // Don't cache HTML files to allow for SPA updates
53- let cache_value = if is_html || is_root {
49+ let cache_value = if is_html {
5450 "no-cache, no-store, must-revalidate"
5551 } else {
5652 "public, max-age=31536000, immutable"
0 commit comments