From febcea09fa4cd13404f1a1116bda546aa9c81c7d Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Mon, 16 Jun 2025 16:13:24 +0200 Subject: [PATCH] Add debug logging for static file serving MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Debug static path configuration and existence checks - Log static file request processing steps - Track index.html file resolution for root path requests - Help diagnose why index.html isn't being served for URLs with query params 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- tty-fwd/src/api_server.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tty-fwd/src/api_server.rs b/tty-fwd/src/api_server.rs index b3e28464..a820e412 100644 --- a/tty-fwd/src/api_server.rs +++ b/tty-fwd/src/api_server.rs @@ -115,8 +115,11 @@ fn serve_static_file(static_root: &Path, request_path: &str) -> Option cleaned: '{}' -> file_path: '{}'", request_path, cleaned_path, file_path.display()); + // Security check: ensure the file path is within the static root if !file_path.starts_with(static_root) { + println!("Security check failed: file_path does not start with static_root"); return None; } @@ -149,7 +152,9 @@ fn serve_static_file(static_root: &Path, request_path: &str) -> Option Some( Response::builder() @@ -171,9 +176,11 @@ fn serve_static_file(static_root: &Path, request_path: &str) -> Option exists: {}, is_dir: {}", static_dir, static_dir_path.exists(), static_dir_path.is_dir()); if static_dir_path.exists() && static_dir_path.is_dir() { if let Some(static_response) = serve_static_file(static_dir_path, &path) { let _ = req.respond(static_response); return; } } + } else { + println!("No static_path configured"); } }