Skip to content

Fix http fetch cors#186

Merged
wyhaya merged 3 commits into
mainfrom
fix-fetch
May 25, 2026
Merged

Fix http fetch cors#186
wyhaya merged 3 commits into
mainfrom
fix-fetch

Conversation

@wyhaya
Copy link
Copy Markdown
Member

@wyhaya wyhaya commented May 25, 2026

Fix #185

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.fetch usage with @tauri-apps/plugin-http (tauriFetch) in web code paths.
  • Remove the custom Rust http::fetch command 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 making send itself async) 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 thread package.json
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 thread capabilities/default.json
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'
}
@wyhaya wyhaya merged commit e9495c4 into main May 25, 2026
1 check passed
@wyhaya wyhaya deleted the fix-fetch branch May 25, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] made AI provider support on Opencode Zen & Go

2 participants