コンテンツにスキップ
Tauri

HTTP クライアント

http プラグインを使用して HTTP リクエストを行います。

This plugin requires a Rust version of at least 1.77.2

Platform Level Notes
windows
linux
macos
android
ios

http プラグインをインストールして開始します。

プロジェクトのパッケージマネージャーを使用して依存関係を追加します:

npm run tauri add http

HTTP プラグインは、reqwest の再エクスポートとして Rust で、また JavaScript で使用できます。

  1. 許可された URL を構成する

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

    詳細については、権限の概要のドキュメントを参照してください。

  2. リクエストを送信する

    fetch メソッドは、可能な限り fetch Web API に近づけ、準拠しようとします。

    import { fetch } from '@tauri-apps/plugin-http';
    // GET リクエストを送信する
    const response = await fetch('http://test.tauri.app/data.json', {
    method: 'GET',
    });
    console.log(response.status); // 例: 200
    console.log(response.statusText); // 例: "OK"

Rust では、プラグインによって再エクスポートされた reqwest クレートを利用できます。詳細については、reqwest のドキュメントを参照してください。

use tauri_plugin_http::reqwest;
let res = reqwest::get("http://my.api.host/data.json").await;
println!("{:?}", res.status()); // 例: 200
println!("{:?}", res.text().await); // 例: Ok("{ Content }")

Default Permission

This permission set configures what kind of fetch operations are available from the http plugin.

This enables all fetch operations but does not allow explicitly any origins to be fetched. This needs to be manually configured before usage.

Granted Permissions

All fetch operations are enabled.

This default permission set includes the following:

  • allow-fetch
  • allow-fetch-cancel
  • allow-fetch-read-body
  • allow-fetch-send

Permission Table

Identifier Description

http:allow-fetch

Enables the fetch command without any pre-configured scope.

http:deny-fetch

Denies the fetch command without any pre-configured scope.

http:allow-fetch-cancel

Enables the fetch_cancel command without any pre-configured scope.

http:deny-fetch-cancel

Denies the fetch_cancel command without any pre-configured scope.

http:allow-fetch-read-body

Enables the fetch_read_body command without any pre-configured scope.

http:deny-fetch-read-body

Denies the fetch_read_body command without any pre-configured scope.

http:allow-fetch-send

Enables the fetch_send command without any pre-configured scope.

http:deny-fetch-send

Denies the fetch_send command without any pre-configured scope.


© 2025 Tauri Contributors. CC-BY / MIT