Skip to content

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode,DeepSeek Harness and more. Only official website: ccswitch.io

fix(proxy): route every subprocess through the global proxy

Jason54d0faaed78e
diff --git a/src-tauri/src/commands/misc.rs b/src-tauri/src/commands/misc.rs
index b7473ac81..e5449af55 100644
--- a/src-tauri/src/commands/misc.rs
+++ b/src-tauri/src/commands/misc.rs
@@ -644,6 +644,8 @@ fn run_tool_lifecycle_silently(
}
apply_login_shell_vars(&mut cmd, &login_env.vars);
}
+ // npm / 官方安装脚本只认 HTTPS_PROXY 这类变量,不读设置里的全局代理。
+ crate::services::claude_account::login::apply_global_proxy_env(&mut cmd);
let output = tool_lifecycle_progress::run_with_progress(cmd, progress)
.map_err(|e| format!("启动安装进程失败: {e}"))?;
finish_lifecycle_output(&output)
@@ -665,10 +667,10 @@ fn run_tool_lifecycle_silently(
let bat_file = script_dir.path().join(format!("{label}.bat"));
std::fs::write(&bat_file, command_line).map_err(|e| format!("写入批处理文件失败: {e}"))?;
- let output = tool_lifecycle_progress::run_with_progress(
- windows_lifecycle_command(&bat_file, &effective_path_string()),
- progress,
- );
+ let mut command = windows_lifecycle_command(&bat_file, &effective_path_string());
+ // npm / 官方安装脚本只认 HTTPS_PROXY 这类变量,不读设置里的全局代理(WSL 里的安装不经这里)。
+ crate::services::claude_account::login::apply_global_proxy_env(&mut command);
+ let output = tool_lifecycle_progress::run_with_progress(command, progress);
finish_lifecycle_output(&output.map_err(|e| format!("启动安装进程失败: {e}"))?)
}
diff --git a/src-tauri/src/commands/session_manager.rs b/src-tauri/src/commands/session_manager.rs
index 89a771ce4..958263fc7 100644
--- a/src-tauri/src/commands/session_manager.rs
+++ b/src-tauri/src/commands/session_manager.rs
@@ -230,7 +230,10 @@ pub async fn launch_session_terminal(
crate::commands::terminal_launch::open_agy_resume_terminal(&provider, &conversation, cwd)?;
return Ok(true);
}
- let command = command.clone();
+ let command = with_resume_proxy(
+ &command,
+ crate::proxy::http_client::get_current_proxy_url().as_deref(),
+ );
let cwd = cwd.clone();
let custom_config = custom_config.clone();
@@ -258,6 +261,33 @@ pub async fn launch_session_terminal(
Ok(true)
}
+/// 把设置里的全局代理加在恢复命令前面(`NAME=值 命令`,用户 shell 的 alias / 函数照常生效)。
+///
+/// 这条命令会原样显示在终端里,所以带用户名、密码的代理不加,免得凭据露在屏幕和历史里;
+/// 规则同「打开终端」:agy(Go)也传 SOCKS5,其余只传 http(s) 并让本机地址直连。
+fn with_resume_proxy(command: &str, proxy_url: Option<&str>) -> String {
+ let Some(url) = proxy_url else {
+ return command.to_string();
+ };
+ if url::Url::parse(url.trim())
+ .is_ok_and(|parsed| !parsed.username().is_empty() || parsed.password().is_some())
+ {
+ log::info!("全局代理带凭据,恢复会话的命令里不加代理");
+ return command.to_string();
+ }
+ let go_client = command.trim_start().starts_with("agy ");
+ let vars =
+ crate::services::claude_account::login::global_proxy_env(url, go_client, |_| go_client);
+ if vars.is_empty() {
+ return command.to_string();
+ }
+ let assignments: Vec<String> = vars
+ .iter()
+ .map(|(name, value)| format!("{name}={}", session_manager::terminal::shell_escape(value)))
+ .collect();
+ format!("{} {command}", assignments.join(" "))
+}
+
#[tauri::command]
pub async fn delete_session(
providerId: String,
diff --git a/src-tauri/src/commands/session_manager_tests.rs b/src-tauri/src/commands/session_manager_tests.rs
index d4b751517..1462e951d 100644
--- a/src-tauri/src/commands/session_manager_tests.rs
+++ b/src-tauri/src/commands/session_manager_tests.rs
@@ -85,3 +85,31 @@ fn failed_session_stream_still_sends_an_error_packet() {
[json!({"type":"error", "message":error})]
);
}
+
+#[test]
+fn resume_command_carries_the_global_proxy() {
+ let http = "http://127.0.0.1:7890";
+ assert_eq!(
+ with_resume_proxy("claude --resume abc", Some(http)),
+ "HTTPS_PROXY='http://127.0.0.1:7890' https_proxy='http://127.0.0.1:7890' \
+ HTTP_PROXY='http://127.0.0.1:7890' http_proxy='http://127.0.0.1:7890' \
+ NO_PROXY='localhost,127.0.0.1,::1' no_proxy='localhost,127.0.0.1,::1' claude --resume abc"
+ );
+ // agy (Go) takes SOCKS5 too and needs no NO_PROXY; Node clients skip a SOCKS-only proxy
+ assert_eq!(
+ with_resume_proxy("agy --conversation=x", Some("socks5h://127.0.0.1:1080")),
+ "HTTPS_PROXY='socks5://127.0.0.1:1080' https_proxy='socks5://127.0.0.1:1080' \
+ HTTP_PROXY='socks5://127.0.0.1:1080' http_proxy='socks5://127.0.0.1:1080' \
+ agy --conversation=x"
+ );
+ assert_eq!(
+ with_resume_proxy("codex resume x", Some("socks5://127.0.0.1:1080")),
+ "codex resume x"
+ );
+ // No proxy, or one carrying credentials that would show in the terminal: unchanged
+ assert_eq!(with_resume_proxy("codex resume x", None), "codex resume x");
+ assert_eq!(
+ with_resume_proxy("codex resume x", Some("http://user:[email protected]:7890")),
+ "codex resume x"
+ );
+}
diff --git a/src-tauri/src/commands/terminal_launch.rs b/src-tauri/src/commands/terminal_launch.rs
index 3017228f9..b00a01069 100644
--- a/src-tauri/src/commands/terminal_launch.rs
+++ b/src-tauri/src/commands/terminal_launch.rs
@@ -359,6 +359,11 @@ struct ProviderLaunch {
batch_vars: Vec<(&'static str, String)>,
/// 退出时删除的临时文件,都在系统临时目录里
cleanup: Vec<PathBuf>,
+ /// 设置里的全局代理(`add_global_proxy_env` 填)。和 `env` 不同,macOS / Linux 上不经
+ /// `env` 前缀,而是导出给运行命令的用户 shell:`env` 直接执行程序,会跳过用户给
+ /// `claude` 这类命令定义的 alias / 函数;代价是用户 rc 里自己 export 的代理优先。
+ /// Windows 和 `env` 一样写进 `setlocal` 段。
+ proxy_env: Vec<(&'static str, String)>,
}
impl ProviderLaunch {
@@ -556,6 +561,7 @@ fn codex_launch(
env,
batch_vars,
cleanup,
+ proxy_env: Vec::new(),
})
}
@@ -602,6 +608,7 @@ fn grok_launch(grok_home: String) -> ProviderLaunch {
env: vec![("GROK_HOME", Some(grok_home))],
batch_vars: Vec::new(),
cleanup: Vec::new(),
+ proxy_env: Vec::new(),
}
}
@@ -637,6 +644,7 @@ fn claude_terminal_launch(
env: Vec::new(),
batch_vars: Vec::new(),
cleanup: vec![config_file],
+ proxy_env: Vec::new(),
})
}
@@ -670,6 +678,7 @@ fn claude_account_terminal_launch(config_dir: Option<PathBuf>) -> ProviderLaunch
env,
batch_vars: Vec::new(),
cleanup: Vec::new(),
+ proxy_env: Vec::new(),
}
}
@@ -695,6 +704,7 @@ fn agy_terminal_launch(provider: &crate::provider::Provider) -> Result<ProviderL
env: launch.env,
batch_vars,
cleanup: Vec::new(),
+ proxy_env: Vec::new(),
});
};
Ok(ProviderLaunch {
@@ -706,14 +716,15 @@ fn agy_terminal_launch(provider: &crate::provider::Provider) -> Result<ProviderL
env: launch.env,
batch_vars: vec![(AGY_DIR_BATCH_VAR, dir.to_string_lossy().into_owned())],
cleanup: Vec::new(),
+ proxy_env: Vec::new(),
})
}
/// 把设置里的全局代理交给终端里启动的这一个客户端(#10119)。
///
/// 全局代理只作用于 CC Switch 进程内的请求;终端里的 CLI 只认 `HTTPS_PROXY` 这类变量、
-/// 不读系统代理,用户 shell 里没 export 时会直连出去。变量只给这一个进程,盖过用户 rc
-/// 里的同名值。
+/// 不读系统代理,用户 shell 里没 export 时会直连出去。变量只给这一次启动(见
+/// `ProviderLaunch::proxy_env`),用户 rc 里自己 export 的代理优先。
/// - 卡片自己配了代理(任一代理变量,不分大小写;Claude 的在临时 settings 的 `env` 里)
/// 就整组不加,免得大小写两套变量指向不同代理;卡片设了 NO_PROXY 也以卡片为准。
/// - agy(Go)也传 SOCKS5,不补 NO_PROXY:Go 本来就不代理 localhost 和回环地址。
@@ -746,7 +757,7 @@ fn add_global_proxy_env<'a>(
crate::services::claude_account::login::global_proxy_env(url, go_client, |_| go_client);
for (key, value) in vars {
if !card_has(key) {
- launch.env.push((key, Some(value)));
+ launch.proxy_env.push((key, value));
}
}
}
@@ -894,6 +905,7 @@ fn copilot_launch_command(
env,
batch_vars,
cleanup: Vec::new(),
+ proxy_env: Vec::new(),
})
}
@@ -1036,6 +1048,12 @@ fn unix_launch_env_file(launch: &ProviderLaunch) -> String {
.as_ref()
.map(|value| format!("{LAUNCH_ENV_PREFIX}{index}={}\n", shell_single_quote(value)))
})
+ .chain(
+ launch
+ .proxy_env
+ .iter()
+ .map(|(name, value)| format!("{name}={}\n", shell_single_quote(value))),
+ )
.collect()
}
@@ -1083,8 +1101,10 @@ fn build_unix_launcher_script(
// exec 不会触发 EXIT trap,所以在换成交互 shell 之前自己删。
script.push_str(&remove_temp_files);
script.push('\n');
+ // 代理只给这一次启动,不留给之后的交互 shell(它自己会按 rc 重新设置)。
let launch_vars: Vec<String> = (0..launch.env.len())
.map(|index| format!("{LAUNCH_ENV_PREFIX}{index}"))
+ .chain(launch.proxy_env.iter().map(|(name, _)| name.to_string()))
.collect();
if !launch_vars.is_empty() {
script.push_str(&format!("unset {}\n", launch_vars.join(" ")));
@@ -1738,6 +1758,7 @@ fn build_windows_launch_env(launch: &ProviderLaunch) -> (String, Vec<(String, St
launch
.batch_vars
.iter()
+ .chain(&launch.proxy_env)
.map(|(name, value)| (*name, Some(value.clone()))),
);
for (index, (name, value)) in entries.enumerate() {
@@ -2066,7 +2087,12 @@ fn build_running_unix_script(
command_line: &str,
label: &str,
exit_file: Option<&Path>,
+ proxy_env: &[(&'static str, String)],
) -> String {
+ let proxy: String = proxy_env
+ .iter()
+ .map(|(name, value)| format!("export {name}={}\n", shell_single_quote(value)))
+ .collect();
let cleanup = shell_single_quote(&format!(
"rm -f -- {}",
shell_single_quote(&script_file.to_string_lossy())
@@ -2081,12 +2107,22 @@ fn build_running_unix_script(
})
.unwrap_or_default();
format!(
- "#!/usr/bin/env sh\ntrap {cleanup} EXIT\ncd \"$HOME\" 2>/dev/null || true\necho \"[cc-switch] Starting: {label}\"\necho \"\"\n{command_line}\n{exit_record}echo \"\"\necho \"[cc-switch] Command exited. Press Enter to close.\"\nread -r _\n"
+ "#!/usr/bin/env sh\ntrap {cleanup} EXIT\ncd \"$HOME\" 2>/dev/null || true\necho \"[cc-switch] Starting: {label}\"\necho \"\"\n{proxy}{command_line}\n{exit_record}echo \"\"\necho \"[cc-switch] Command exited. Press Enter to close.\"\nread -r _\n"
)
}
#[cfg_attr(not(windows), allow(dead_code))]
-fn build_running_windows_bat(command_line: &str, label: &str, exit_file: Option<&Path>) -> String {
+fn build_running_windows_bat(
+ command_line: &str,
+ label: &str,
+ exit_file: Option<&Path>,
+ proxy_env: &[(&'static str, String)],
+) -> String {
+ // 在 DisableDelayedExpansion 之后设置,密码里的 `!` 不会被吃掉
+ let proxy: String = proxy_env
+ .iter()
+ .map(|(name, value)| format!("set \"{name}={}\"\r\n", value.replace('%', "%%")))
+ .collect();
let exit_record = exit_file
.map(|path| {
let escaped = path.to_string_lossy().replace('%', "%%");
@@ -2097,7 +2133,7 @@ fn build_running_windows_bat(command_line: &str, label: &str, exit_file: Option<
})
.unwrap_or_default();
format!(
- "@echo off\r\ncd /d \"%USERPROFILE%\" 2>nul\r\necho [cc-switch] Starting: {label}\r\necho.\r\n{command_line}\r\n{exit_record}echo.\r\necho [cc-switch] Command exited. Press any key to close.\r\npause >nul\r\ndel \"%~f0\" >nul 2>&1\r\n"
+ "@echo off\r\nsetlocal DisableDelayedExpansion\r\ncd /d \"%USERPROFILE%\" 2>nul\r\necho [cc-switch] Starting: {label}\r\necho.\r\n{proxy}{command_line}\r\n{exit_record}echo.\r\necho [cc-switch] Command exited. Press any key to close.\r\npause >nul\r\ndel \"%~f0\" >nul 2>&1\r\n"
)
}
@@ -2107,19 +2143,34 @@ fn build_running_windows_bat(command_line: &str, label: &str, exit_file: Option<
///
/// **Security**:`command_line` 会被原样拼进 shell/batch 脚本,调用方必须
/// 保证它是可信字符串(当前只由后端硬编码调用)。
+///
+/// 设置里配了全局代理时,代理变量写在脚本里交给命令(脚本只给本人读写)。agy 登录自己
+/// 把代理拼进命令(含 SOCKS5),走 [`launch_terminal_running_with_exit_file`],不经这里。
pub(crate) fn launch_terminal_running(command_line: &str, label: &str) -> Result<(), String> {
- launch_terminal_running_with_exit_file(command_line, label, None)
+ let proxy_env = crate::proxy::http_client::get_current_proxy_url()
+ .map(|url| crate::services::claude_account::login::global_proxy_env(&url, false, |_| false))
+ .unwrap_or_default();
+ launch_terminal_with_script(command_line, label, None, &proxy_env)
}
pub(crate) fn launch_terminal_running_with_exit_file(
command_line: &str,
label: &str,
exit_file: Option<&Path>,
+) -> Result<(), String> {
+ launch_terminal_with_script(command_line, label, exit_file, &[])
+}
+
+fn launch_terminal_with_script(
+ command_line: &str,
+ label: &str,
+ exit_file: Option<&Path>,
+ proxy_env: &[(&'static str, String)],
) -> Result<(), String> {
#[cfg(any(target_os = "macos", target_os = "linux"))]
let (script_file, script_content) = {
let file = unique_temp_path(&format!("cc_switch_{label}"), "sh");
- let content = build_running_unix_script(&file, command_line, label, exit_file);
+ let content = build_running_unix_script(&file, command_line, label, exit_file, proxy_env);
(file, content)
};
@@ -2200,7 +2251,7 @@ pub(crate) fn launch_terminal_running_with_exit_file(
let terminal = preferred.as_deref().unwrap_or("cmd");
let bat_file = unique_temp_path(&format!("cc_switch_{label}"), "bat");
- let content = build_running_windows_bat(command_line, label, exit_file);
+ let content = build_running_windows_bat(command_line, label, exit_file, proxy_env);
std::fs::write(&bat_file, &content).map_err(|e| format!("写入批处理文件失败: {e}"))?;
let bat_path = bat_file.to_string_lossy();
@@ -2570,6 +2621,7 @@ mod tests {
r"C:\Users\张三\.cc-switch\agy\relay".to_string(),
)],
cleanup: Vec::new(),
+ proxy_env: Vec::new(),
}
}
@@ -2764,27 +2816,28 @@ mod tests {
env,
batch_vars: Vec::new(),
cleanup: Vec::new(),
+ proxy_env: Vec::new(),
};
let with_proxy = |app: AppType, url: Option<&str>| {
let mut launch = launch(Vec::new());
add_global_proxy_env(&mut launch, &app, std::iter::empty(), url);
- launch.env
+ launch.proxy_env
};
// agy (Go): SOCKS5 too, socks5h becomes socks5, NO_PROXY left to the user (#10119)
assert_eq!(
with_proxy(AppType::Agy, Some("socks5h://127.0.0.1:1080")),
proxy_keys
- .map(|key| (key, Some("socks5://127.0.0.1:1080".to_string())))
+ .map(|key| (key, "socks5://127.0.0.1:1080".to_string()))
.to_vec()
);
// Other clients: http(s) only, and the local router stays off the proxy
let mut expected: Vec<_> = proxy_keys
- .map(|key| (key, Some("http://127.0.0.1:7890".to_string())))
+ .map(|key| (key, "http://127.0.0.1:7890".to_string()))
.to_vec();
expected.extend(
- ["NO_PROXY", "no_proxy"].map(|key| (key, Some("localhost,127.0.0.1,::1".to_string()))),
+ ["NO_PROXY", "no_proxy"].map(|key| (key, "localhost,127.0.0.1,::1".to_string())),
);
for app in [
AppType::Claude,
@@ -2808,10 +2861,7 @@ mod tests {
std::iter::empty(),
Some("http://127.0.0.1:7890"),
);
- assert_eq!(
- card.env,
- vec![("HTTPS_PROXY", Some("http://card:1".to_string()))]
- );
+ assert!(card.proxy_env.is_empty());
// Claude keeps its card env in the temporary settings file, not in `launch.env`
let mut claude = launch(Vec::new());
@@ -2821,7 +2871,7 @@ mod tests {
["ANTHROPIC_BASE_URL", "https_proxy"],
Some("http://127.0.0.1:7890"),
);
- assert!(claude.env.is_empty());
+ assert!(claude.proxy_env.is_empty());
// A card NO_PROXY (either case) wins; the proxy itself still applies
let mut no_proxy = launch(Vec::new());
@@ -2832,11 +2882,37 @@ mod tests {
Some("http://127.0.0.1:7890"),
);
assert_eq!(
- no_proxy.env,
+ no_proxy.proxy_env,
proxy_keys
- .map(|key| (key, Some("http://127.0.0.1:7890".to_string())))
+ .map(|key| (key, "http://127.0.0.1:7890".to_string()))
.to_vec()
);
+
+ // The proxy is exported to the user's shell, not put behind an `env` prefix (which would
+ // skip a `claude` alias or function), and is dropped before the interactive shell takes over.
+ let mut proxied = launch(Vec::new());
+ add_global_proxy_env(
+ &mut proxied,
+ &AppType::Agy,
+ std::iter::empty(),
+ Some("http://user:pa'[email protected]:7890"),
+ );
+ assert_eq!(unix_launch_command(&proxied), "claude");
+ let env_file = unix_launch_env_file(&proxied);
+ assert!(env_file.starts_with("HTTPS_PROXY='http://user:pa'\"'\"'[email protected]:7890'\n"));
+ let script = build_unix_launcher_script(
+ &proxied,
+ "/bin/bash",
+ None,
+ Path::new("/tmp/launcher.sh"),
+ Some(Path::new("/tmp/env.sh")),
+ );
+ assert!(!script.contains("7890"));
+ let run = script.find("'/bin/bash' -ic 'claude'").unwrap();
+ let unset = script
+ .find("unset HTTPS_PROXY https_proxy HTTP_PROXY http_proxy\n")
+ .unwrap();
+ assert!(script.find(". '/tmp/env.sh'").unwrap() < run && run < unset);
}
#[test]
@@ -3121,7 +3197,7 @@ mod tests {
fn running_scripts_set_home_cwd_quote_cleanup_and_record_exit_status() {
let script = Path::new("/tmp/it's dir/cc_switch_agy_login_1.sh");
let exit_file = Path::new("/tmp/it's dir/exit.status");
- let unix = build_running_unix_script(script, "agy", "agy_login", Some(exit_file));
+ let unix = build_running_unix_script(script, "agy", "agy_login", Some(exit_file), &[]);
assert!(unix.contains("cd \"$HOME\" 2>/dev/null || true\n"));
assert!(unix.contains("trap 'rm -f -- '\"'\"'/tmp/it'\"'\"'\"'\"'\"'\"'\"'\"'s dir/cc_switch_agy_login_1.sh'\"'\"'' EXIT"));
let rc_pos = unix.find("_cc_switch_rc=$?").unwrap();
@@ -3133,6 +3209,7 @@ mod tests {
"agy",
"agy_login",
Some(Path::new(r"C:\Temp\exit%1.status")),
+ &[],
);
assert!(bat.contains("cd /d \"%USERPROFILE%\" 2>nul\r\n"));
let err_pos = bat.find("set \"_CC_SWITCH_RC=%ERRORLEVEL%\"").unwrap();
@@ -3153,7 +3230,7 @@ mod tests {
let script = tricky.join("run.sh");
let exit_file = tricky.join("exit.status");
let content =
- build_running_unix_script(&script, "(exit 42)", "test_exit", Some(&exit_file));
+ build_running_unix_script(&script, "(exit 42)", "test_exit", Some(&exit_file), &[]);
std::fs::write(&script, content).unwrap();
std::fs::set_permissions(&script, std::fs::Permissions::from_mode(0o755)).unwrap();
diff --git a/src-tauri/src/proxy/http_client.rs b/src-tauri/src/proxy/http_client.rs
index d7094725e..941516fc0 100644
--- a/src-tauri/src/proxy/http_client.rs
+++ b/src-tauri/src/proxy/http_client.rs
@@ -364,6 +364,18 @@ pub(crate) fn no_redirect_with_proxy(
)
}
+/// 用调用方自己的参数建客户端,代理规则同 [`get_for_url`]:本机地址直连,其余走设置里的
+/// 全局代理,没配时跟随系统代理。
+pub(crate) fn build_for_url(builder: reqwest::ClientBuilder, url: &str) -> Result<Client, String> {
+ if is_loopback_url(url) {
+ return builder
+ .no_proxy()
+ .build()
+ .map_err(|e| format!("Failed to build HTTP client: {e}"));
+ }
+ build_client_from(builder, get_current_proxy_url().as_deref())
+}
+
/// 不跟随重定向、按目标地址选代理的客户端:本机地址直连,其余同 [`no_redirect`]。
pub fn no_redirect_for_url(url: &str) -> Result<Client, String> {
if is_loopback_url(url) {
diff --git a/src-tauri/src/services/mcp_connectivity.rs b/src-tauri/src/services/mcp_connectivity.rs
index b5fa59bdc..d0d2483f0 100644
--- a/src-tauri/src/services/mcp_connectivity.rs
+++ b/src-tauri/src/services/mcp_connectivity.rs
@@ -156,6 +156,26 @@ async fn connect(
let inherited = std::env::var("PATH").unwrap_or_default();
apply_login_shell_path(&mut command, login_path.as_deref(), &inherited);
}
+ // 设置里的全局代理也给检测拉起的服务(npx / uvx 首次运行要下载包);配置里
+ // 自己写了代理的以配置为准,整组不加,免得大小写两套变量指向不同代理。
+ let configures_proxy = spec.env.keys().any(|key| {
+ ["HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY"]
+ .iter()
+ .any(|name| key.eq_ignore_ascii_case(name))
+ });
+ if !configures_proxy {
+ if let Some(url) = crate::proxy::http_client::get_current_proxy_url() {
+ let set_by_config = |key: &str| {
+ std::env::var_os(key).is_some()
+ || spec.env.keys().any(|name| name.eq_ignore_ascii_case(key))
+ };
+ command.envs(crate::services::claude_account::login::global_proxy_env(
+ &url,
+ false,
+ set_by_config,
+ ));
+ }
+ }
command
.args(&spec.args)
.envs(&spec.env)
@@ -193,12 +213,14 @@ async fn connect(
reqwest::header::HeaderValue::from_str(value)?,
);
}
- let client = reqwest::Client::builder()
- .default_headers(headers)
- .connect_timeout(CHECK_TIMEOUT)
- .timeout(CHECK_TIMEOUT)
- .redirect(reqwest::redirect::Policy::none())
- .build()?;
+ let client = crate::proxy::http_client::build_for_url(
+ reqwest::Client::builder()
+ .default_headers(headers)
+ .connect_timeout(CHECK_TIMEOUT)
+ .timeout(CHECK_TIMEOUT)
+ .redirect(reqwest::redirect::Policy::none()),
+ url,
+ )?;
if transport == "sse" {
let transport = SseClientTransport::start_with_client(
SameOriginSseClient {
diff --git a/src-tauri/src/session_manager/terminal/mod.rs b/src-tauri/src/session_manager/terminal/mod.rs
index 4abffe997..6bbe79c3e 100644
--- a/src-tauri/src/session_manager/terminal/mod.rs
+++ b/src-tauri/src/session_manager/terminal/mod.rs
@@ -323,7 +323,7 @@ fn launch_warp(command: &str, cwd: Option<&str>) -> Result<(), String> {
rm -- "$0"
- exec {command}
+ exec env {command}
"#,
)
.map_err(|e| format!("Failed to write to temporary script file for Warp: {e}"))?;