fix: change api endpoint

This commit is contained in:
Leafd 2025-10-03 17:57:08 -04:00
parent 0c44596bb5
commit 2c5eccb596
3 changed files with 9 additions and 63 deletions

View file

@ -36,60 +36,16 @@ struct ApiConfig {
impl Default for ApiConfig {
fn default() -> Self {
Self {
base_url: "http://localhost:3000".to_string(),
base_url: "http://dogwood.local:3000".to_string(),
}
}
}
impl ApiConfig {
fn from_config_file() -> Result<Self, Box<dyn std::error::Error>> {
let possible_paths = vec![
Path::new("config.json"),
Path::new("../config.json"),
Path::new("../../config.json"),
];
let mut config_path = None;
for path in &possible_paths {
println!("Checking for config file at: {:?}", path);
if path.exists() {
config_path = Some(path);
break;
}
fn new() -> Self {
Self {
base_url: "http://dogwood.local:3000".to_string(),
}
let config_path = match config_path {
Some(path) => path,
None => {
println!("Config file not found in any expected location");
let default_config = ApiConfig::default();
println!("Using default config: {:?}", default_config);
return Ok(default_config);
}
};
println!("Found config file at: {:?}", config_path);
println!("Config file exists, reading content...");
let config_content = fs::read_to_string(config_path)?;
println!("Config file content: {}", config_content);
let config: serde_json::Value = serde_json::from_str(&config_content)?;
if let Some(api_config) = config.get("api") {
if let Some(base_url) = api_config.get("base_url") {
if let Some(url) = base_url.as_str() {
println!("Found API base_url in config: {}", url);
return Ok(ApiConfig {
base_url: url.to_string(),
});
}
}
}
println!("Could not find api.base_url in config file");
let default_config = ApiConfig::default();
println!("Using default config: {:?}", default_config);
Ok(default_config)
}
}
@ -2093,7 +2049,7 @@ pub fn run() {
.plugin(tauri_plugin_updater::Builder::new().build())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_deep_link::init())
.manage(ApiConfig::from_config_file().unwrap_or_else(|_| ApiConfig::default()))
.manage(ApiConfig::new())
.manage(Arc::new(tauri::async_runtime::Mutex::new(AuthState {
is_authenticated: false,
access_token: None,

View file

@ -40,9 +40,6 @@
"icons/icon.icns",
"icons/icon.ico"
],
"resources": [
"../config.json"
],
"macOS": {
"entitlements": "entitlements.plist",
"hardenedRuntime": true,
@ -54,16 +51,9 @@
"open": true
},
"deepLink": {
"schemes": [
"hackatime"
],
"windows": [
{
"title": "Hackatime Desktop",
"width": 800,
"height": 600
}
]
"desktop": {
"schemes": ["hackatime"]
}
},
"updater": {
"pubkey": "dW50cnVzdGVkIGNvbW1lbnQ6IG1pbmlzaWduIHB1YmxpYyBrZXk6IDdERjg4QTFCNTJFMDk0MUQKUldRZGxPQlNHNHI0ZlRkMDN0MGI1MnllY1dUVStZalV3dVdhcTFuREx5SGtBc0txQ2xnTWs3WU4K",

View file

@ -11,7 +11,7 @@ interface AuthState {
}
export class KubeTimeApi {
private baseUrl: string = "http://localhost:3000";
private baseUrl: string = "http://dogwood.local:3000";
private accessToken: string | null = null;
private latestPresenceCache: { data: any | null; fetchedAt: number } = { data: null, fetchedAt: 0 };