From 9dd62746fffde2f075e4952d074e4146cbf91e64 Mon Sep 17 00:00:00 2001 From: Niko Korvenlaita Date: Mon, 14 Oct 2024 14:28:13 +0300 Subject: [PATCH 1/3] Allow http calls without origin header Example Clerk auth provider does not work when both Authorization and Origin headers are set. This allows one to skip setting the origin header explicitly. --- plugins/http/src/commands.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/http/src/commands.rs b/plugins/http/src/commands.rs index cda21bd532..39a68973ac 100644 --- a/plugins/http/src/commands.rs +++ b/plugins/http/src/commands.rs @@ -264,6 +264,14 @@ pub async fn fetch( } } + // In case empty origin is passed, remove it. Some services do not like Origin header + // so this way we can remove it in explicit way. The default behaviour is still to set it + if cfg!(feature = "unsafe-headers") + && headers.get(header::ORIGIN) == Some(&HeaderValue::from_static("")) + { + headers.remove(header::ORIGIN); + }; + if let Some(data) = data { request = request.body(data); } From 5b4e2b6f1911a2ae1ed3128d32cbe1b348cef4e1 Mon Sep 17 00:00:00 2001 From: Niko Korvenlaita Date: Wed, 16 Oct 2024 07:34:20 +0300 Subject: [PATCH 2/3] add changes entry --- .changes/http-allow-skip-origin.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/http-allow-skip-origin.md diff --git a/.changes/http-allow-skip-origin.md b/.changes/http-allow-skip-origin.md new file mode 100644 index 0000000000..cbc8fab5d6 --- /dev/null +++ b/.changes/http-allow-skip-origin.md @@ -0,0 +1,6 @@ +--- +"http": "patch" +"http-js": "patch" +--- + +Allow skipping sending Origin header in HTTP requests by sending empty string as the value for Origin header. From 943de579dbd0a628f97c0ec63d938b7f77b92e71 Mon Sep 17 00:00:00 2001 From: Niko Korvenlaita Date: Wed, 16 Oct 2024 15:08:50 +0300 Subject: [PATCH 3/3] Update .changes/http-allow-skip-origin.md Co-authored-by: Amr Bashir --- .changes/http-allow-skip-origin.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/http-allow-skip-origin.md b/.changes/http-allow-skip-origin.md index cbc8fab5d6..9906224555 100644 --- a/.changes/http-allow-skip-origin.md +++ b/.changes/http-allow-skip-origin.md @@ -3,4 +3,4 @@ "http-js": "patch" --- -Allow skipping sending Origin header in HTTP requests by sending empty string as the value for Origin header. +Allow skipping sending `Origin` header in HTTP requests by setting `Origin` header to an empty string when calling `fetch`.