feat: allow http calls without origin header (#1941)

This commit is contained in:
Niko Korvenlaita
2024-10-16 15:56:36 +03:00
committed by GitHub
parent 558e14bb4c
commit cfd48b3b2e
2 changed files with 14 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
---
"http": "patch"
"http-js": "patch"
---
Allow skipping sending `Origin` header in HTTP requests by setting `Origin` header to an empty string when calling `fetch`.
+8
View File
@@ -264,6 +264,14 @@ pub async fn fetch<R: Runtime>(
}
}
// 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);
}