Skip to content

Commit d8a2de4

Browse files
runkidsclaude
andcommitted
fix(deploy): use compile-time env var for Netlify OAuth client ID
- Change from runtime std::env::var to compile-time option_env! - This ensures the client ID is embedded in the packaged binary - Required for macOS apps which don't inherit shell environment variables 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 5b02be0 commit d8a2de4

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

src-tauri/src/commands/deploy.rs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ pub struct CheckAccountResult {
3030

3131
// OAuth client configuration
3232
//
33-
// These values are intentionally loaded from environment variables so we don't
34-
// hardcode credentials in the repo.
35-
const ENV_NETLIFY_CLIENT_ID: &str = "PACKAGEFLOW_NETLIFY_CLIENT_ID";
33+
// These values are loaded from environment variables at COMPILE TIME using option_env!
34+
// This ensures they are embedded in the binary for packaged apps.
35+
// Set PACKAGEFLOW_NETLIFY_CLIENT_ID when building for release.
36+
const NETLIFY_CLIENT_ID: Option<&str> = option_env!("PACKAGEFLOW_NETLIFY_CLIENT_ID");
3637

3738
/// OAuth success page HTML - displayed after successful authorization
3839
const OAUTH_SUCCESS_HTML: &str = r##"<!DOCTYPE html>
@@ -180,26 +181,20 @@ enum OAuthClientConfig {
180181
Netlify { client_id: String },
181182
}
182183

183-
fn read_env_trimmed(key: &str) -> Option<String> {
184-
std::env::var(key)
185-
.ok()
186-
.map(|v| v.trim().to_string())
187-
.filter(|v| !v.is_empty())
188-
}
189-
190184
fn get_oauth_client_config(platform: &PlatformType) -> Result<OAuthClientConfig, String> {
191185
match platform {
192186
PlatformType::GithubPages => {
193187
Err("GitHub Pages does not require OAuth. It uses git credentials.".to_string())
194188
}
195189
PlatformType::Netlify => {
196-
let client_id = read_env_trimmed(ENV_NETLIFY_CLIENT_ID).ok_or_else(|| {
197-
format!(
198-
"Netlify OAuth is not configured. Set {}.",
199-
ENV_NETLIFY_CLIENT_ID
200-
)
201-
})?;
202-
Ok(OAuthClientConfig::Netlify { client_id })
190+
let client_id = NETLIFY_CLIENT_ID
191+
.filter(|s| !s.trim().is_empty())
192+
.ok_or_else(|| {
193+
"Netlify OAuth is not configured. Set PACKAGEFLOW_NETLIFY_CLIENT_ID.".to_string()
194+
})?;
195+
Ok(OAuthClientConfig::Netlify {
196+
client_id: client_id.to_string(),
197+
})
203198
}
204199
PlatformType::CloudflarePages => {
205200
Err("Cloudflare Pages uses API Token authentication, not OAuth.".to_string())

0 commit comments

Comments
 (0)