debug
This commit is contained in:
@@ -342,6 +342,14 @@ async fn serve_static_file(ctx: &ServerContext) -> Result<GurtResponse> {
|
|||||||
.and_then(|h| h.to_str().ok())
|
.and_then(|h| h.to_str().ok())
|
||||||
.unwrap_or("");
|
.unwrap_or("");
|
||||||
|
|
||||||
|
// Debug logging
|
||||||
|
log::info!("Static file request - Path: '{}', Host header: '{}'", path, host_header);
|
||||||
|
log::info!("All headers: {:?}", ctx.request.headers());
|
||||||
|
|
||||||
|
// 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
|
// Strip query parameters from the path for static file serving
|
||||||
let path_without_query = if let Some(query_pos) = path.find('?') {
|
let path_without_query = if let Some(query_pos) = path.find('?') {
|
||||||
&path[..query_pos]
|
&path[..query_pos]
|
||||||
@@ -350,9 +358,11 @@ async fn serve_static_file(ctx: &ServerContext) -> Result<GurtResponse> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let file_path = if path_without_query == "/" || path_without_query == "" {
|
let file_path = if path_without_query == "/" || path_without_query == "" {
|
||||||
if host_header == "search.web" {
|
if hostname == "search.web" {
|
||||||
|
log::info!("Serving search.html for search.web domain");
|
||||||
"search.html"
|
"search.html"
|
||||||
} else {
|
} else {
|
||||||
|
log::info!("Serving index.html for domain: '{}'", hostname);
|
||||||
"index.html"
|
"index.html"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -372,13 +382,16 @@ async fn serve_static_file(ctx: &ServerContext) -> Result<GurtResponse> {
|
|||||||
let current_dir = std::env::current_dir()
|
let current_dir = std::env::current_dir()
|
||||||
.map_err(|_| GurtError::invalid_message("Failed to get current directory"))?;
|
.map_err(|_| GurtError::invalid_message("Failed to get current directory"))?;
|
||||||
|
|
||||||
let frontend_dir = if host_header == "search.web" {
|
let frontend_dir = if hostname == "search.web" {
|
||||||
|
log::info!("Using search-engine frontend directory");
|
||||||
current_dir.join("search-engine").join("frontend")
|
current_dir.join("search-engine").join("frontend")
|
||||||
} else {
|
} else {
|
||||||
|
log::info!("Using default frontend directory");
|
||||||
current_dir.join("frontend")
|
current_dir.join("frontend")
|
||||||
};
|
};
|
||||||
|
|
||||||
let full_path = frontend_dir.join(file_path);
|
let full_path = frontend_dir.join(file_path);
|
||||||
|
log::info!("Attempting to serve file: '{}'", full_path.display());
|
||||||
|
|
||||||
match tokio::fs::read_to_string(&full_path).await {
|
match tokio::fs::read_to_string(&full_path).await {
|
||||||
Ok(content) => {
|
Ok(content) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user