feat: added compile time environment variable for setting the api url

this allows easy local testing
This commit is contained in:
antifallobst 2023-10-04 22:36:27 +02:00
parent e6bf8ffa68
commit 6c915ef56d
Signed by: antifallobst
GPG Key ID: 2B4F402172791BAF
2 changed files with 2 additions and 9 deletions

View File

@ -39,20 +39,13 @@ pub struct Session {
impl Default for Session { impl Default for Session {
fn default() -> Self { fn default() -> Self {
Self { Self {
base_url: "https://api.nerdcult.net".to_owned(), base_url: option_env!("NC_API_URL").unwrap_or("https://api.nerdcult.net").to_string(),
auth_token: get_auth_cookie(), auth_token: get_auth_cookie(),
} }
} }
} }
impl Session { impl Session {
pub fn new(base_url: String) -> Self {
Self {
base_url,
auth_token: get_auth_cookie(),
}
}
pub fn login( pub fn login(
&self, &self,
username: String, username: String,

View File

@ -43,7 +43,7 @@ pub struct Callbacks {
#[function_component] #[function_component]
fn App() -> Html { fn App() -> Html {
// let state = use_state(Session::default); // let state = use_state(Session::default);
let state = use_state(|| Session::new("http://localhost:8080".to_string())); let state = use_state(Session::default);
let cloned_state = state.clone(); let cloned_state = state.clone();
let callbacks = use_state(move || Callbacks { let callbacks = use_state(move || Callbacks {