fix some browser bug

This commit is contained in:
Face
2025-09-08 20:19:50 +03:00
parent 3b87ab39c9
commit ac261e7d18
6 changed files with 30 additions and 17 deletions

View File

@@ -342,12 +342,7 @@ async fn serve_static_file(ctx: &ServerContext) -> Result<GurtResponse> {
.map(|s| s.as_str())
.unwrap_or("");
// Debug logging
log::info!("Static file request - Path: '{}', Host header: '{}'", path, host_header);
// Extract hostname without port
let hostname = host_header.split(':').next().unwrap_or(host_header);
log::info!("Extracted hostname: '{}'", hostname);
// Strip query parameters from the path for static file serving
let path_without_query = if let Some(query_pos) = path.find('?') {
@@ -358,10 +353,8 @@ async fn serve_static_file(ctx: &ServerContext) -> Result<GurtResponse> {
let file_path = if path_without_query == "/" || path_without_query == "" {
if hostname == "search.web" {
log::info!("Serving search.html for search.web domain");
"search.html"
} else {
log::info!("Serving index.html for domain: '{}'", hostname);
"index.html"
}
} else {
@@ -382,15 +375,12 @@ async fn serve_static_file(ctx: &ServerContext) -> Result<GurtResponse> {
.map_err(|_| GurtError::invalid_message("Failed to get current directory"))?;
let frontend_dir = if hostname == "search.web" {
log::info!("Using search-engine frontend directory");
current_dir.join("search-engine").join("frontend")
} else {
log::info!("Using default frontend directory");
current_dir.join("frontend")
};
let full_path = frontend_dir.join(file_path);
log::info!("Attempting to serve file: '{}' from directory: '{}'", full_path.display(), frontend_dir.display());
match tokio::fs::read_to_string(&full_path).await {
Ok(content) => {

View File

@@ -27,21 +27,16 @@ pub(crate) async fn index(ctx: &ServerContext, _app_state: AppState) -> Result<G
let hostname = host_header.split(':').next().unwrap_or(host_header);
log::info!("Index handler - Host header: '{}', hostname: '{}'", host_header, hostname);
let current_dir = std::env::current_dir()
.map_err(|_| GurtError::invalid_message("Failed to get current directory"))?;
let (frontend_dir, file_name) = if hostname == "search.web" {
log::info!("Index handler serving search.html for search.web domain");
(current_dir.join("search-engine").join("frontend"), "search.html")
} else {
log::info!("Index handler serving index.html for domain: '{}'", hostname);
(current_dir.join("frontend"), "index.html")
};
let index_path = frontend_dir.join(file_name);
log::info!("Index handler attempting to read: '{}'", index_path.display());
match tokio::fs::read_to_string(&index_path).await {
Ok(content) => {