Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(app): treat tauri.localhost on a non-default port as external

M3gA-Mind5123d6d12417
diff --git a/crates/openhuman-app/src/external_navigation.rs b/crates/openhuman-app/src/external_navigation.rs
index 3f9ff623ee..0141cc7b6d 100644
--- a/crates/openhuman-app/src/external_navigation.rs
+++ b/crates/openhuman-app/src/external_navigation.rs
@@ -26,13 +26,16 @@ const MAIN_WINDOW: &str = "main";
/// App origins that stay in the webview:
/// - any non-`http(s)` scheme: `tauri://localhost` (macOS/Linux), `about:`,
/// `blob:`, `data:`;
-/// - `http(s)://tauri.localhost` (Windows);
+/// - `http(s)://tauri.localhost` on its default port (Windows); any other port
+/// is a different origin, e.g. a loopback service, and is handed off;
/// - the dev server origin, passed as `dev_url` only under `tauri dev`.
pub(crate) fn navigation_handoff(label: &str, url: &Url, dev_url: Option<&Url>) -> Option<Url> {
if label != MAIN_WINDOW || !matches!(url.scheme(), "http" | "https") {
return None;
}
- if url.host_str() == Some("tauri.localhost")
+ // `Url` drops a scheme's default port, so `port()` is `None` only for the
+ // canonical `http(s)://tauri.localhost` origins.
+ if (url.host_str() == Some("tauri.localhost") && url.port().is_none())
|| dev_url.is_some_and(|dev| dev.origin() == url.origin())
{
return None;
diff --git a/crates/openhuman-app/src/external_navigation_tests.rs b/crates/openhuman-app/src/external_navigation_tests.rs
index aab8f13e1f..96f0b66ac8 100644
--- a/crates/openhuman-app/src/external_navigation_tests.rs
+++ b/crates/openhuman-app/src/external_navigation_tests.rs
@@ -12,6 +12,8 @@ fn remote_pages_are_cancelled_and_handed_to_the_os_browser() {
// Loopback that is not the dev server is still a remote page to the webview.
"http://localhost:8000/",
"https://tauri.localhost.example.com/",
+ // Same host, different origin: a loopback service on another port.
+ "http://tauri.localhost:8000/",
] {
assert_eq!(
navigation_handoff("main", &url(href), None),