File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ http : patch
3+ http-js : patch
4+ ---
5+
6+ Fixed an issue that caused the Origin header to always be ` null ` on macOS, iOS and Linux.
Original file line number Diff line number Diff line change @@ -279,7 +279,7 @@ pub async fn fetch<R: Runtime>(
279279
280280 if headers. contains_key ( header:: RANGE ) {
281281 // https://fetch.spec.whatwg.org/#http-network-or-cache-fetch step 18
282- // If httpRequest’ s header list contains `Range`, then append (`Accept-Encoding`, `identity`)
282+ // If httpRequest' s header list contains `Range`, then append (`Accept-Encoding`, `identity`)
283283 headers. append ( header:: ACCEPT_ENCODING , HeaderValue :: from_str ( "identity" ) ?) ;
284284 }
285285
@@ -290,10 +290,13 @@ pub async fn fetch<R: Runtime>(
290290 // ensure we have an Origin header set
291291 if cfg ! ( not( feature = "unsafe-headers" ) ) || !headers. contains_key ( header:: ORIGIN ) {
292292 if let Ok ( url) = webview. url ( ) {
293- headers. append (
294- header:: ORIGIN ,
295- HeaderValue :: from_str ( & url. origin ( ) . ascii_serialization ( ) ) ?,
296- ) ;
293+ // The url crate returns OpaqueOrigin for tauri://localhost which serializes to "null"
294+ let origin = if url. scheme ( ) == "tauri" {
295+ "tauri://localhost" . to_string ( )
296+ } else {
297+ url. origin ( ) . ascii_serialization ( )
298+ } ;
299+ headers. append ( header:: ORIGIN , HeaderValue :: from_str ( & origin) ?) ;
297300 }
298301 }
299302
You can’t perform that action at this time.
0 commit comments