Skip to content
Tauri 中文网

@tauri-apps/plugin-http

Make HTTP requests with the Rust backend.

Security

This API has a scope configuration that forces you to restrict the URLs that can be accessed using glob patterns.

For instance, this scope configuration only allows making HTTP requests to all subdomains for tauri.app except for https://private.tauri.app:

{
"permissions": [
{
"identifier": "http:default",
"allow": [{ "url": "https://*.tauri.app" }],
"deny": [{ "url": "https://private.tauri.app" }]
}
]
}

Trying to execute any API with a URL not configured on the scope results in a promise rejection due to denied access.

Interfaces

ClientOptions

Options to configure the Rust client used to make fetch requests

Since

2.0.0

Properties

PropertyTypeDescriptionDefined in
connectTimeout?numberTimeout in millisecondsSource: undefined
danger?DangerousSettingsConfiguration for dangerous settings on the client such as disabling SSL verification.Source: undefined
maxRedirections?numberDefines the maximum number of redirects the client should follow. If set to 0, no redirects will be followed.Source: undefined
proxy?ProxyConfiguration of a proxy that a Client should pass requests to.Source: undefined

DangerousSettings

Configuration for dangerous settings on the client such as disabling SSL verification.

Since

2.3.0

Properties

PropertyTypeDescriptionDefined in
acceptInvalidCerts?booleanDisables SSL verification.Source: undefined
acceptInvalidHostnames?booleanDisables hostname verification.Source: undefined

Proxy

Configuration of a proxy that a Client should pass requests to.

Since

2.0.0

Properties

PropertyTypeDescriptionDefined in
all?string | ProxyConfigProxy all traffic to the passed URL.Source: undefined
http?string | ProxyConfigProxy all HTTP traffic to the passed URL.Source: undefined
https?string | ProxyConfigProxy all HTTPS traffic to the passed URL.Source: undefined

ProxyConfig

Properties

PropertyTypeDescriptionDefined in
basicAuth?objectSet the Proxy-Authorization header using Basic auth.Source: undefined
basicAuth.passwordstring-Source: undefined
basicAuth.usernamestring-Source: undefined
noProxy?stringA configuration for filtering out requests that shouldn’t be proxied. Entries are expected to be comma-separated (whitespace between entries is ignored)Source: undefined
urlstringThe URL of the proxy server.Source: undefined

Functions

fetch()

function fetch(input, init?): Promise<Response>

Fetch a resource from the network. It returns a Promise that resolves to the Response to that Request, whether it is successful or not.

Parameters

ParameterType
inputstring | URL | Request
init?RequestInit & ClientOptions

Returns

Promise<Response>

Example

const response = await fetch("http://my.json.host/data.json");
console.log(response.status); // e.g. 200
console.log(response.statusText); // e.g. "OK"
const jsonData = await response.json();

Since

2.0.0

Source: undefined


Tauri 中文网 - 粤ICP备13048890号