diff --git a/crates/outbound-http/src/lib.rs b/crates/outbound-http/src/lib.rs index a92df0c511..6d6358bbdd 100644 --- a/crates/outbound-http/src/lib.rs +++ b/crates/outbound-http/src/lib.rs @@ -53,9 +53,10 @@ impl outbound_http::Host for OutboundHttp { .map_err(|_| HttpError::RuntimeError)? { tracing::log::info!("Destination not allowed: {}", req.uri); - terminal::warn!("A component tried to make a HTTP request to '{}'.", req.uri); - eprintln!("The component was configured not to allow requests to this host."); - eprintln!("To allow requests, add the host to `allowed_http_posts`."); + if let Some(host) = host(&req.uri) { + terminal::warn!("A component tried to make a HTTP request to non-allowed host '{host}'."); + eprintln!("To allow requests, add 'allowed_http_hosts = [\"{host}\"]' to the component manifest."); + } return Err(HttpError::DestinationNotAllowed); } @@ -170,3 +171,9 @@ fn response_headers(h: &HeaderMap) -> anyhow::Result Option { + url::Url::parse(url) + .ok() + .and_then(|u| u.host().map(|h| h.to_string())) +}