diff --git a/src/config.rs b/src/config.rs index ecbb13e..dd83e77 100644 --- a/src/config.rs +++ b/src/config.rs @@ -234,7 +234,7 @@ impl Default for Config { } impl Config { - pub fn url(&self, inner: Uri, http: bool) -> Result { + pub fn uri_parts(&self, inner: Uri, http: bool) -> Result { let mut uri_parts = inner.into_parts(); let scheme = match (self.use_tls, http) { (false, false) => Scheme::from_str("ws").unwrap(), @@ -245,6 +245,6 @@ impl Config { uri_parts.scheme = Some(scheme); let authority = Authority::from_str(&format!("{}:{}", self.hostname, self.port))?; uri_parts.authority = Some(authority); - Ok(Uri::from_parts(uri_parts)?) + Ok(uri_parts) } } diff --git a/src/web/management/auth.rs b/src/web/management/auth.rs index d33932b..bc0816b 100644 --- a/src/web/management/auth.rs +++ b/src/web/management/auth.rs @@ -86,7 +86,11 @@ pub async fn check_auth(request: Request) -> Result { if let Some(u) = tags.get_value(b"u") { let auth_url = String::from_utf8(u.to_owned())?; let actual_url = { - let uri = GLOBALS.config.read().url(request.uri().to_owned(), true)?; + let uri_parts = GLOBALS + .config + .read() + .uri_parts(request.uri().to_owned(), true)?; + let uri = http::Uri::from_parts(uri_parts)?; format!("{}", uri) }; diff --git a/src/web/mod.rs b/src/web/mod.rs index b626ccb..23c5775 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -43,6 +43,8 @@ pub async fn serve_http( } } + let uri = request.uri().to_owned(); + // Try blossom if enabled if GLOBALS.config.read().blossom_directory.is_some() { match blossom::handle(&request).await { @@ -55,7 +57,8 @@ pub async fn serve_http( } } - log::debug!(target: "Client", "{}: HTTP request for {}", peer, request.uri()); + log::debug!(target: "Client", "{}: HTTP request for {}", peer, uri); + let response = Response::builder() .header("Access-Control-Allow-Origin", "*") .header("Access-Control-Allow-Headers", "*")