From da8a7bbe3afd4acf56a37cd811fe836564c41af7 Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Wed, 5 Jun 2024 19:57:36 +0300 Subject: [PATCH] fix(http): fix check logic to decide whether to set `Origin` header (#1438) ref: https://github.com/tauri-apps/plugins-workspace/issues/1389#issuecomment-2150470335 --- .changes/http-origin-duplicated.md | 5 +++++ plugins/http/src/commands.rs | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changes/http-origin-duplicated.md diff --git a/.changes/http-origin-duplicated.md b/.changes/http-origin-duplicated.md new file mode 100644 index 00000000..67d1c9b6 --- /dev/null +++ b/.changes/http-origin-duplicated.md @@ -0,0 +1,5 @@ +--- +"http": "patch" +--- + +Fix `ORIGIN` header containing 2 URLs when `unsafe-headers` feature flag is enabled. diff --git a/plugins/http/src/commands.rs b/plugins/http/src/commands.rs index 5c895ebc..ac4b8c6a 100644 --- a/plugins/http/src/commands.rs +++ b/plugins/http/src/commands.rs @@ -224,8 +224,8 @@ pub async fn fetch( request = request.header(header::USER_AGENT, "tauri-plugin-http"); } - if !(cfg!(feature = "unsafe-headers") - && headers.contains_key(header::ORIGIN.as_str())) + if cfg!(feature = "unsafe-headers") + && !headers.contains_key(header::ORIGIN.as_str()) { if let Ok(url) = webview.url() { request =