Conversation
There was a problem hiding this comment.
Pull request overview
This PR switches the app’s HTTP requests from a custom Tauri invoke-based fetch to @tauri-apps/plugin-http to address CORS limitations, and removes the now-unneeded Rust/TS HTTP bridge.
Changes:
- Replace custom
Http.fetchusage with@tauri-apps/plugin-http(tauriFetch) in web code paths. - Remove the custom Rust
http::fetchcommand and the TS wrapper module. - Add the Tauri HTTP plugin + capability permissions, and update JS/Rust dependencies accordingly.
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src-web/utils/license.ts | Uses tauriFetch instead of the removed custom Http.fetch. |
| src-web/tauri/index.ts | Stops re-exporting the removed HTTP wrapper module. |
| src-web/tauri/http.ts | Deletes the old invoke('fetch') wrapper implementation. |
| src-web/pages/settings/provider/api.ts | Uses tauriFetch for provider model discovery calls. |
| src-web/pages/database/ai/services.ts | Injects tauriFetch into AI SDK clients to avoid browser fetch/CORS. |
| src-tauri/main.rs | Registers tauri_plugin_http and removes the old command handler. |
| src-tauri/http.rs | Deletes the old Rust fetch command implementation. |
| capabilities/default.json | Adds http:default allow rules required by the HTTP plugin. |
| package.json | Adds @tauri-apps/plugin-http dependency. |
| pnpm-lock.yaml | Locks @tauri-apps/plugin-http and its transitive dependencies. |
| Cargo.toml | Adds tauri-plugin-http and removes the now-unused app-level reqwest dependency entry. |
| Cargo.lock | Updates the resolved Rust dependency graph to include tauri-plugin-http. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (1)
src-web/utils/license.ts:85
- Avoid wrapping an async operation in
new Promise(async ...)here. Using an async IIFE (or makingsenditselfasync) prevents the async Promise executor anti-pattern and ensures thrown errors reject the returned promise predictably.
return new Promise(async (success, error) => {
try {
let res = await tauriFetch(url.toString(), {
method: data.method,
headers: {
'Content-Type': 'application/json'
},
body
})
if (res.status !== 200) {
const rst: { message: string } = await res.json()
return error(rst.message)
}
success(await res.json())
} catch (err: any) {
error(err.toString())
}
})
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
27
to
32
| "@tauri-apps/api": "^2.10.1", | ||
| "@tauri-apps/plugin-clipboard-manager": "^2.3.2", | ||
| "@tauri-apps/plugin-dialog": "^2.7.0", | ||
| "@tauri-apps/plugin-fs": "^2.5.0", | ||
| "@tauri-apps/plugin-http": "^2.5.9", | ||
| "@tauri-apps/plugin-opener": "^2.5.3", |
Comment on lines
+36
to
+40
| { "url": "https://*" }, | ||
| { "url": "https://*:*" }, | ||
| { "url": "http://*" }, | ||
| { "url": "http://*:*" } | ||
| ] |
Comment on lines
+105
to
+110
| const headers = { | ||
| 'x-api-key': config.apiKey, | ||
| 'anthropic-version': '2023-06-01', | ||
| 'anthropic-dangerous-direct-browser-access': 'true', | ||
| 'dangerouslyAllowBrowser': 'true' | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #185