prevent macOS HTTPS upgrade for localhost resources

This commit is contained in:
2026-09-05 10:21:18 -07:00
parent f46869f967
commit 33e285953c
5 changed files with 67 additions and 39 deletions

View File

@@ -658,6 +658,17 @@ fn main() {
.initialization_script(LINK_HANDLER_SCRIPT)
.build()?;
#[cfg(target_os = "macos")]
{
use objc2::msg_send;
use objc2::runtime::AnyObject;
let _ = window.with_webview(|webview| unsafe {
let wk_webview = webview.inner() as *mut AnyObject;
let config: *mut AnyObject = msg_send![wk_webview, configuration];
let _: () = msg_send![config, setUpgradeKnownHostsToHTTPS: false];
});
}
let (main_js, root_dir) = resolve_script_and_root(app);
debug_log("Searching for node binary...");
let node_bin = match find_node_binary(app) {
@@ -858,9 +869,15 @@ fn main() {
window_label
));
}
} else {
let _ = w.emit(&msg.event, msg.data.clone());
}
} else if msg.event == "ready" {
if let Some(url_str) = msg.data.get("url").and_then(|u| u.as_str()) {
if let Ok(url_parsed) = url_str.parse::<tauri::Url>() {
let _ = w.navigate(url_parsed);
}
}
} else {
let _ = w.emit(&msg.event, msg.data.clone());
}
}
}
});