summaryrefslogtreecommitdiffhomepage
path: root/packages/desktop/src-tauri/src/server.rs
diff options
context:
space:
mode:
authorBrendan Allan <[email protected]>2026-02-20 12:18:39 +0800
committerBrendan Allan <[email protected]>2026-02-20 12:18:39 +0800
commit1c2416b6deb1eee856d1fddbf08300cf851a19fc (patch)
tree39da283d0d2ad02c2c092099bf47ab726ef9244b /packages/desktop/src-tauri/src/server.rs
parentd86c10816d75837c8f85e7b1ab0de5ff37ecf77b (diff)
downloadopencode-1c2416b6deb1eee856d1fddbf08300cf851a19fc.tar.gz
opencode-1c2416b6deb1eee856d1fddbf08300cf851a19fc.zip
desktop: don't spawn sidecar if default is localhost server
Diffstat (limited to 'packages/desktop/src-tauri/src/server.rs')
-rw-r--r--packages/desktop/src-tauri/src/server.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/packages/desktop/src-tauri/src/server.rs b/packages/desktop/src-tauri/src/server.rs
index a13b450bb..2c43c1cc8 100644
--- a/packages/desktop/src-tauri/src/server.rs
+++ b/packages/desktop/src-tauri/src/server.rs
@@ -150,7 +150,7 @@ pub async fn check_health(url: &str, password: Option<&str>) -> bool {
return false;
};
- let mut builder = reqwest::Client::builder().timeout(Duration::from_secs(3));
+ let mut builder = reqwest::Client::builder().timeout(Duration::from_secs(7));
if url_is_localhost(&url) {
// Some environments set proxy variables (HTTP_PROXY/HTTPS_PROXY/ALL_PROXY) without
@@ -178,6 +178,10 @@ pub async fn check_health(url: &str, password: Option<&str>) -> bool {
.unwrap_or(false)
}
+pub fn is_localhost_url(url: &str) -> bool {
+ reqwest::Url::parse(url).is_ok_and(|u| url_is_localhost(&u))
+}
+
fn url_is_localhost(url: &reqwest::Url) -> bool {
url.host_str().is_some_and(|host| {
host.eq_ignore_ascii_case("localhost")