fix some problems with url origins in web (denoising works there too)
This commit is contained in:
@@ -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"
|
||||
|
||||
+9
-8
@@ -405,14 +405,16 @@ pub fn load_username() -> Option<String> {
|
||||
.ok()?
|
||||
}
|
||||
|
||||
pub fn absolute_url(path: &str) -> Result<Url, Error> {
|
||||
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<ClientConfig> {
|
||||
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<Vec<u8>> {
|
||||
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;
|
||||
|
||||
+5
-1
@@ -39,6 +39,7 @@ fn default_cert_alt_names() -> Vec<String> {
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
struct Config {
|
||||
public_url: Url,
|
||||
proxy_url: Option<Url>,
|
||||
https_listen_address: SocketAddr,
|
||||
http_listen_address: Option<SocketAddr>,
|
||||
cert_path: Option<PathBuf>,
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user