docs: update WebViewBuilder::with_asynchronous_custom_protocol with platform-specific notes (#12830)

This commit is contained in:
Simon Laux
2025-02-27 02:10:08 +01:00
committed by GitHub
parent b859dc43fc
commit 4bffc326ea
2 changed files with 42 additions and 0 deletions

View File

@@ -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: `<scheme_name>://<path>` (so it will be `my-scheme://path/to/page).
/// - Windows and Android: `http://<scheme_name>.<path>` 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<String>,
@@ -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: `<scheme_name>://<path>` (so it will be `my-scheme://path/to/page).
/// - Windows and Android: `http://<scheme_name>.<path>` 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<String>,

View File

@@ -554,6 +554,16 @@ impl<R: Runtime, C: DeserializeOwned> Builder<R, C> {
/// .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: `<scheme_name>://<path>` (so it will be `my-scheme://path/to/page).
/// - Windows and Android: `http://<scheme_name>.<path>` by default (so it will be `http://my-scheme.path/to/page`).
#[must_use]
pub fn register_uri_scheme_protocol<
N: Into<String>,
@@ -617,6 +627,16 @@ impl<R: Runtime, C: DeserializeOwned> Builder<R, C> {
/// .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: `<scheme_name>://<path>` (so it will be `my-scheme://path/to/page).
/// - Windows and Android: `http://<scheme_name>.<path>` by default (so it will be `http://my-scheme.path/to/page`).
#[must_use]
pub fn register_asynchronous_uri_scheme_protocol<
N: Into<String>,