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 {
|
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,
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue