fix some problems with url origins in web (denoising works there too)
This commit is contained in:
+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;
|
||||
|
||||
Reference in New Issue
Block a user