diff options
| author | 2026-03-12 15:34:30 +0800 | |
|---|---|---|
| committer | 2026-03-12 15:34:30 +0800 | |
| commit | 792bd3260839faffb004741e78c81b0c6acd5d08 (patch) | |
| tree | 9d0b4cbeb58fee82772da90782e2fe652face2d5 /src-tauri/src/core/modpack.rs | |
| parent | 8cfc2cff7e8d8afaa7870474deb80008230357f1 (diff) | |
| download | DropOut-792bd3260839faffb004741e78c81b0c6acd5d08.tar.gz DropOut-792bd3260839faffb004741e78c81b0c6acd5d08.zip | |
fix(modpack): make CURSEFORGE_API_KEY optional for dev
Diffstat (limited to 'src-tauri/src/core/modpack.rs')
| -rw-r--r-- | src-tauri/src/core/modpack.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src-tauri/src/core/modpack.rs b/src-tauri/src/core/modpack.rs index 5ac9493..2998167 100644 --- a/src-tauri/src/core/modpack.rs +++ b/src-tauri/src/core/modpack.rs @@ -294,8 +294,6 @@ fn parse_multimc(archive: &mut Archive) -> Result<ParsedModpack, String> { // ── CurseForge API resolution ───────────────────────────────────────────── -const CURSEFORGE_API_KEY: &str = env!("CURSEFORGE_API_KEY"); - async fn resolve_curseforge_files(files: &[ModpackFile]) -> Result<Vec<ModpackFile>, String> { let file_ids: Vec<u64> = files .iter() @@ -368,9 +366,15 @@ async fn cf_post( endpoint: &str, body: &serde_json::Value, ) -> Result<serde_json::Value, String> { + let api_key = std::env::var("CURSEFORGE_API_KEY") + .map_err(|_| "CURSEFORGE_API_KEY is not set".to_string())?; + if api_key.trim().is_empty() { + return Err("CURSEFORGE_API_KEY is empty".to_string()); + } + let resp = client .post(format!("https://api.curseforge.com{endpoint}")) - .header("x-api-key", CURSEFORGE_API_KEY) + .header("x-api-key", api_key) .json(body) .send() .await |