Skip to content

[bug] Upload Plugin not using Authorization Header #2538

Open
@zeru-t

Description

@zeru-t

Describe the bug

When using the release asset url of a public repository, the download API correctly start downloading the file.

When using the @tauri-apps/plugin-upload download function to get a private GitHub repositories release asset, the request responds with:

error sending request for url (https://api.github.com/repos/USER/REPO/releases/assets/ASST_ID)

Reproduction

  1. Install the plugin and import the JavaScript API.
  2. Call the API with the following:
    a. URL: the api.github.com download url of a private release assets (see: https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#get-a-release-asset)
    b. TOKEN: pass your github Personal access token as the Authorization header

This is how I have implemented this plugin using a React frontend:

import { download } from '@tauri-apps/plugin-upload';

export function DownloadComponent() {

	useEffect(() => {
		downloadFile();
	}, []);


	async function downloadFile() {
		const path = './download/fileName.zip';
		const url = 'https://api.github.com/repos/USER/REPO/releases/assets/ASST_ID';
		await download(
			url,
			path,
			progress,
			new Map([[ 'Authorization', 'token GITHUB_TOKEN' ]])
		);
	}

	function progress({ progressTotal, total }: any ) {
		console.log('progressTotal: ' + progressTotal + ', total: ' + total);
	}


	return (
		<div>
			<h1>Downloading...</h1>
		</div>
	);
}

Image

Image

Expected behavior

The download function should pass the auth header to the requested url and begin downloading the contents of the file.

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.26100 x86_64 (X64)
    ✔ WebView2: 133.0.3065.92
    ✔ MSVC:
        - Visual Studio Build Tools 2022
        - Visual Studio Community 2022
    ✔ rustc: 1.84.0 (9fc6b4312 2025-01-07)
    ✔ cargo: 1.84.0 (66221abde 2024-11-19)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.11.0
    - npm: 10.2.4
    - bun: 1.2.5

[-] Packages
    - tauri 🦀: 2.2.3
    - tauri-build 🦀: 2.0.5
    - wry 🦀: 0.48.1
    - tao 🦀: 0.31.1
    - @tauri-apps/api : 2.3.0
    - @tauri-apps/cli : 2.3.1

[-] Plugins
    - tauri-plugin-autostart 🦀: 2.2.0
    - @tauri-apps/plugin-autostart : 2.2.0
    - tauri-plugin-process 🦀: 2.2.0
    - @tauri-apps/plugin-process : 2.2.0
    - tauri-plugin-upload 🦀: 2.2.1
    - @tauri-apps/plugin-upload : 2.2.1
    - tauri-plugin-shell 🦀: 2.2.0
    - @tauri-apps/plugin-shell : 2.2.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/

Stack trace

N/A

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingplugin: http-extraFormer "upload" plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions