diff --git a/crates/tauri/src/app.rs b/crates/tauri/src/app.rs index e5ec678ff..8a6a2099f 100644 --- a/crates/tauri/src/app.rs +++ b/crates/tauri/src/app.rs @@ -1727,6 +1727,17 @@ tauri::Builder::default() /// } /// }); /// ``` + /// + /// # Warning + /// + /// Pages loaded from custom protocol will have different Origin on different platforms. And + /// servers which enforce CORS will need to add exact same Origin header in `Access-Control-Allow-Origin` + /// if you wish to send requests with native `fetch` and `XmlHttpRequest` APIs. Here are the + /// different Origin headers across platforms: + /// + /// - macOS, iOS and Linux: `://` (so it will be `my-scheme://path/to/page). + /// - Windows and Android: `http://.` by default (so it will be `http://my-scheme.path/to/page`). + /// To use `https` instead of `http`, use [`super::webview::WebviewBuilder::use_https_scheme`]. #[must_use] pub fn register_uri_scheme_protocol< N: Into, @@ -1784,6 +1795,17 @@ tauri::Builder::default() /// }); /// }); /// ``` + /// + /// # Warning + /// + /// Pages loaded from custom protocol will have different Origin on different platforms. And + /// servers which enforce CORS will need to add exact same Origin header in `Access-Control-Allow-Origin` + /// if you wish to send requests with native `fetch` and `XmlHttpRequest` APIs. Here are the + /// different Origin headers across platforms: + /// + /// - macOS, iOS and Linux: `://` (so it will be `my-scheme://path/to/page). + /// - Windows and Android: `http://.` by default (so it will be `http://my-scheme.path/to/page`). + /// To use `https` instead of `http`, use [`super::webview::WebviewBuilder::use_https_scheme`]. #[must_use] pub fn register_asynchronous_uri_scheme_protocol< N: Into, diff --git a/crates/tauri/src/plugin.rs b/crates/tauri/src/plugin.rs index cac5be984..26cd90c02 100644 --- a/crates/tauri/src/plugin.rs +++ b/crates/tauri/src/plugin.rs @@ -554,6 +554,16 @@ impl Builder { /// .build() /// } /// ``` + /// + /// # Warning + /// + /// Pages loaded from custom protocol will have different Origin on different platforms. And + /// servers which enforce CORS will need to add exact same Origin header in `Access-Control-Allow-Origin` + /// if you wish to send requests with native `fetch` and `XmlHttpRequest` APIs. Here are the + /// different Origin headers across platforms: + /// + /// - macOS, iOS and Linux: `://` (so it will be `my-scheme://path/to/page). + /// - Windows and Android: `http://.` by default (so it will be `http://my-scheme.path/to/page`). #[must_use] pub fn register_uri_scheme_protocol< N: Into, @@ -617,6 +627,16 @@ impl Builder { /// .build() /// } /// ``` + /// + /// # Warning + /// + /// Pages loaded from custom protocol will have different Origin on different platforms. And + /// servers which enforce CORS will need to add exact same Origin header in `Access-Control-Allow-Origin` + /// if you wish to send requests with native `fetch` and `XmlHttpRequest` APIs. Here are the + /// different Origin headers across platforms: + /// + /// - macOS, iOS and Linux: `://` (so it will be `my-scheme://path/to/page). + /// - Windows and Android: `http://.` by default (so it will be `http://my-scheme.path/to/page`). #[must_use] pub fn register_asynchronous_uri_scheme_protocol< N: Into,