fjordgard

A desktop clock application
Log | Files | Refs | README | LICENSE

commit f5c761fec05d9a73c679d60b8291d236df0c771b
parent d83a58eee15ecac710c466e1dfa4ad01bab2a58f
Author: Sylvia Ivory <git@sivory.net>
Date:   Fri, 20 Jun 2025 02:41:42 -0700

Fix CORS error

Diffstat:
Mcrates/weather/src/lib.rs | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/crates/weather/src/lib.rs b/crates/weather/src/lib.rs @@ -10,6 +10,7 @@ use serde::{Serialize, de::DeserializeOwned}; mod error; pub mod model; +#[cfg(not(target_arch = "wasm32"))] const USER_AGENT: &str = concat!("fjordgard/", env!("CARGO_PKG_VERSION")); const GEOCODING_API_HOST: &str = "geocoding-api.open-meteo.com"; const FORECASTING_API_HOST: &str = "api.open-meteo.com"; @@ -21,7 +22,10 @@ pub struct MeteoClient { impl MeteoClient { pub fn new(api_key: Option<&str>) -> Result<Self> { + #[cfg(not(target_arch = "wasm32"))] let client = Client::builder().user_agent(USER_AGENT).build()?; + #[cfg(target_arch = "wasm32")] + let client = Client::new(); Ok(Self { api_key: api_key.map(|k| k.to_string()), @@ -103,7 +107,7 @@ mod tests { .await .unwrap(); - res.get(0).unwrap().clone() + res.first().unwrap().clone() } #[tokio::test]