feat: added compile time environment variable for setting the api url
this allows easy local testing
This commit is contained in:
parent
e6bf8ffa68
commit
6c915ef56d
|
@ -39,20 +39,13 @@ pub struct Session {
|
|||
impl Default for Session {
|
||||
fn default() -> 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(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Session {
|
||||
pub fn new(base_url: String) -> Self {
|
||||
Self {
|
||||
base_url,
|
||||
auth_token: get_auth_cookie(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn login(
|
||||
&self,
|
||||
username: String,
|
||||
|
|
|
@ -43,7 +43,7 @@ pub struct Callbacks {
|
|||
#[function_component]
|
||||
fn App() -> Html {
|
||||
// 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 callbacks = use_state(move || Callbacks {
|
||||
|
|
Loading…
Reference in New Issue