-
Notifications
You must be signed in to change notification settings - Fork 457
feat: allow http calls without origin header #1941
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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("")) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should match on an empty string, because there might be some users who want to send empty string for fetch(url, {
sendOriginHeader: false
});
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is something I was thinking a lot. Like I'd like to avoid adding extra parameters to the fetch and try to keep the fetch as close to global fetch. And in case of patching global fetch with tauri-http (example to get control what fetches actually can be made) the consumers assume standard fetch. Different libraries support some pre/post hooks for different operations that allow example inject headers and such like for custom auth and they operate with the And the syntax of Origin header is: Sending an empty string is invalid format. In case user wants to hide the origin for example privacy reasons they should set it to For these reasons I ended up with sending empty string in the origin header as the mechanism. I hope my reasoning makes sense.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was comparing with how node and deno runtimes behave and both allow setting |
||
| { | ||
| headers.remove(header::ORIGIN); | ||
| }; | ||
|
|
||
| if let Some(data) = data { | ||
| request = request.body(data); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.