diff --git a/docker/proxy-config.toml b/docker/proxy-config.toml index 9ca6d9d..53eade9 100644 --- a/docker/proxy-config.toml +++ b/docker/proxy-config.toml @@ -1,4 +1,5 @@ -public_url = "https://127.0.0.1:4433" +public_url = "https://localhost:64444" +proxy_url = "https://127.0.0.1:4433/proxy" https_listen_address = "127.0.0.1:4433" http_listen_address = "127.0.0.1:4400" mumble_server_url = "127.0.0.1:64738" diff --git a/gui/src/imp/web.rs b/gui/src/imp/web.rs index e36d0f6..b005fbd 100644 --- a/gui/src/imp/web.rs +++ b/gui/src/imp/web.rs @@ -405,14 +405,16 @@ pub fn load_username() -> Option { .ok()? } +pub fn absolute_url(path: &str) -> Result { + let window: web_sys::Window = web_sys::window().expect("no global `window` exists"); + let location = window.location(); + Ok(Url::parse(&location.href().ey()?)?.join(path)?) +} + pub async fn load_config() -> color_eyre::Result { let config_url = match option_env!("MUMBLE_WEB2_GUI_CONFIG_URL") { Some(url) => Url::parse(url)?, - None => { - let window: web_sys::Window = web_sys::window().expect("no global `window` exists"); - let location = window.location(); - Url::parse(&location.href().ey()?)?.join("config")? - } + None => absolute_url("config")?, }; info!("loading config from {}", config_url); @@ -448,9 +450,8 @@ pub fn init_logging() { // TODO: once we update to dioxus 0.7, swap this out with the dioxus-asset-resolver crate pub async fn read_asset_bytes(asset: &dioxus::prelude::Asset) -> color_eyre::Result> { - let path = asset.to_string(); - let path = path.trim_matches('/'); - Ok(reqwest::get(path).await?.bytes().await?.to_vec()) + let url = absolute_url(asset.to_string().trim_matches('/'))?; + Ok(reqwest::get(url).await?.bytes().await?.to_vec()) } pub struct SpawnHandle; diff --git a/proxy/src/main.rs b/proxy/src/main.rs index 2d7c8d5..35031cf 100644 --- a/proxy/src/main.rs +++ b/proxy/src/main.rs @@ -39,6 +39,7 @@ fn default_cert_alt_names() -> Vec { #[derive(Debug, Deserialize, Serialize)] struct Config { public_url: Url, + proxy_url: Option, https_listen_address: SocketAddr, http_listen_address: Option, cert_path: Option, @@ -82,7 +83,10 @@ async fn main() -> Result<()> { .map_err(|e| anyhow!("could not install crypto provider {e:?}"))?; let mut client_config = ClientConfig { - proxy_url: Some(server_config.public_url.join("proxy")?.to_string()), + proxy_url: match &server_config.proxy_url { + Some(url) => Some(url.to_string()), + None => Some(server_config.public_url.join("proxy")?.to_string()), + }, status_url: Some(server_config.public_url.join("status")?.to_string()), cert_hash: None, any_server: false,