Skip to content

Commit b77a8c5

Browse files
NipsuliSir-Thom
authored andcommitted
feat: allow http calls without origin header (tauri-apps#1941)
1 parent 9556205 commit b77a8c5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

.changes/http-allow-skip-origin.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"http": "patch"
3+
"http-js": "patch"
4+
---
5+
6+
Allow skipping sending `Origin` header in HTTP requests by setting `Origin` header to an empty string when calling `fetch`.

plugins/http/src/commands.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,14 @@ pub async fn fetch<R: Runtime>(
264264
}
265265
}
266266

267+
// In case empty origin is passed, remove it. Some services do not like Origin header
268+
// so this way we can remove it in explicit way. The default behaviour is still to set it
269+
if cfg!(feature = "unsafe-headers")
270+
&& headers.get(header::ORIGIN) == Some(&HeaderValue::from_static(""))
271+
{
272+
headers.remove(header::ORIGIN);
273+
};
274+
267275
if let Some(data) = data {
268276
request = request.body(data);
269277
}

0 commit comments

Comments
 (0)