Skip to content

Commit ff365a3

Browse files
committed
feat: add Tauri HTTP plugin for API requests
Add tauri-plugin-http to bypass WebView CORS restrictions when making API requests to GitHub. This fixes the PAT login network error. - Add tauri-plugin-http to Cargo dependencies - Initialize HTTP plugin in lib.rs - Add HTTP permissions for GitHub API in capabilities - Update request.ts to use Tauri fetch when in Tauri environment - Create shared isTauriEnvironment utility in environment.ts
1 parent 808be82 commit ff365a3

File tree

8 files changed

+268
-7
lines changed

8 files changed

+268
-7
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"@tauri-apps/plugin-deep-link": "~2",
3333
"@tauri-apps/plugin-dialog": "~2",
3434
"@tauri-apps/plugin-global-shortcut": "~2",
35+
"@tauri-apps/plugin-http": "^2.5.4",
3536
"@tauri-apps/plugin-log": "~2",
3637
"@tauri-apps/plugin-notification": "~2",
3738
"@tauri-apps/plugin-opener": "^2",

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.lock

Lines changed: 138 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ tauri-plugin-dialog = "2"
3131
tauri-plugin-notification = "2"
3232
tauri-plugin-store = "2"
3333
tauri-plugin-deep-link = "2"
34+
tauri-plugin-http = { version = "2", features = ["rustls-tls"] }
3435

3536
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
3637
tauri-plugin-autostart = "2"

src-tauri/capabilities/default.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@
2626
"global-shortcut:allow-is-registered",
2727
"global-shortcut:allow-register",
2828
"global-shortcut:allow-unregister",
29-
"deep-link:default"
29+
"deep-link:default",
30+
{
31+
"identifier": "http:default",
32+
"allow": [
33+
{ "url": "https://api.github.com/**" },
34+
{ "url": "https://*.github.com/**" },
35+
{ "url": "https://github.com/**" }
36+
]
37+
}
3038
]
3139
}

src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ pub fn run() {
268268
Some(vec!["--hidden"]),
269269
))
270270
.plugin(tauri_plugin_opener::init())
271+
.plugin(tauri_plugin_http::init())
271272
.plugin(tauri_plugin_deep_link::init())
272273
.plugin(tauri_plugin_single_instance::init(|app, args, _cwd| {
273274
// When a second instance is detected, focus the existing window

0 commit comments

Comments
 (0)