diff --git a/node/src/rpc_service/handler/proof_handler.rs b/node/src/rpc_service/handler/proof_handler.rs index f1cda440..788ec241 100644 --- a/node/src/rpc_service/handler/proof_handler.rs +++ b/node/src/rpc_service/handler/proof_handler.rs @@ -11,9 +11,21 @@ use std::sync::Arc; /// Checks if the request host matches the configured proof builder host to prevent forwarding loops. fn is_loop_detected(host: &str, request_host: Option<&str>) -> bool { - if let Some(request_host) = request_host { - host == request_host - || host.starts_with(&format!("{}:", request_host.split(':').next().unwrap_or(""))) + if let Some(req_host) = request_host { + let mut clean_host = host; + + // Remove scheme if present (e.g. "http://") + if let Some(rest) = clean_host.strip_prefix("http://") { + clean_host = rest; + } else if let Some(rest) = clean_host.strip_prefix("https://") { + clean_host = rest; + } + + // Remove trailing slash + clean_host = clean_host.trim_end_matches('/'); + + // Case-insensitive comparison + clean_host.eq_ignore_ascii_case(req_host) } else { false }