From 76cbeef20848d9adf95c0e95ca17058dbf76fe1e Mon Sep 17 00:00:00 2001 From: situ2001 Date: Wed, 23 Apr 2025 09:38:43 +0800 Subject: [PATCH] fix: add proxy URL support to Webview at Rust-side. (#13278) * fix: add proxy URL support to Webview * chore: add .changes file * Change file --- .changes/fix-webview-proxy-url.md | 5 +++++ crates/tauri/src/webview/plugin.rs | 4 ++++ 2 files changed, 9 insertions(+) create mode 100644 .changes/fix-webview-proxy-url.md diff --git a/.changes/fix-webview-proxy-url.md b/.changes/fix-webview-proxy-url.md new file mode 100644 index 000000000..9cdd78637 --- /dev/null +++ b/.changes/fix-webview-proxy-url.md @@ -0,0 +1,5 @@ +--- +'tauri': 'patch:bug' +--- + +Fix JavaScript API `Webview.proxyUrl` had no effect when used in the `Webview` constructor diff --git a/crates/tauri/src/webview/plugin.rs b/crates/tauri/src/webview/plugin.rs index 4824dd5e7..789e55aa1 100644 --- a/crates/tauri/src/webview/plugin.rs +++ b/crates/tauri/src/webview/plugin.rs @@ -15,6 +15,7 @@ mod desktop_commands { use serde::{Deserialize, Serialize}; use tauri_runtime::dpi::{Position, Size}; use tauri_utils::config::{BackgroundThrottlingPolicy, WebviewUrl, WindowConfig}; + use url::Url; use super::*; use crate::{ @@ -46,6 +47,8 @@ mod desktop_commands { window_effects: Option, #[serde(default)] incognito: bool, + #[serde(alias = "proxy-url")] + pub proxy_url: Option, #[serde(default)] zoom_hotkeys_enabled: bool, #[serde(default)] @@ -70,6 +73,7 @@ mod desktop_commands { builder.webview_attributes.accept_first_mouse = config.accept_first_mouse; builder.webview_attributes.window_effects = config.window_effects; builder.webview_attributes.incognito = config.incognito; + builder.webview_attributes.proxy_url = config.proxy_url; builder.webview_attributes.zoom_hotkeys_enabled = config.zoom_hotkeys_enabled; builder.webview_attributes.background_throttling = config.background_throttling; builder.webview_attributes.javascript_disabled = config.javascript_disabled;