From f974709eab0895e89450d70756c6784ff97c9ec3 Mon Sep 17 00:00:00 2001 From: JL Date: Wed, 17 Apr 2024 10:24:39 -0700 Subject: [PATCH] Update HTTP Client Recipe for 2.0 (#2072) * Update HTTP Client Recipe for 2.0 Updates docs for http client recipe to show the 2.0 configuration (scopes are part of permissions) * Update http-client.mdx Adds link to ACL page underneath updated configuration. * fix: fixing indentation for astro --------- Co-authored-by: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> --- src/content/docs/features/http-client.mdx | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/content/docs/features/http-client.mdx b/src/content/docs/features/http-client.mdx index 7e11817111..2432ba8840 100644 --- a/src/content/docs/features/http-client.mdx +++ b/src/content/docs/features/http-client.mdx @@ -66,18 +66,21 @@ The http plugin is available in both as an JavaScript API and in Rust as a [reqw -1. To keep your app safe, configure allowed scope. Read more on [JavaScript API reference](/references/v2/js/http/#security). +1. Configure the allowed URLs ```json - //tauri.conf.json + //src-tauri/capabilities/base.json { - "plugins": { - "http": { - "scope": ["http://my.api.host/*"] - } - } + "permissions": [ + { + "identifier": "http:default", + "allow": [{ "url": "https://*.tauri.app" }], + "deny": [{ "url": "https://private.tauri.app" }] + } + ] } ``` + For more information, please see the documentation for [Access Control Lists](/references/v2/acl/) 2. Send a request @@ -85,7 +88,7 @@ The http plugin is available in both as an JavaScript API and in Rust as a [reqw import { fetch } from '@tauri-apps/plugin-http'; // Send a GET request - const response = await fetch('http://my.api.host/data.json', { + const response = await fetch('http://test.tauri.app/data.json', { method: 'GET', }); console.log(response.status); // e.g. 200