Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Able to set request headers for tauri downloader #3896

Closed
ghostdevv opened this issue Apr 13, 2022 · 4 comments
Closed

[feat] Able to set request headers for tauri downloader #3896

ghostdevv opened this issue Apr 13, 2022 · 4 comments

Comments

@ghostdevv
Copy link

Describe the problem

Currently I am using this cloudflare worker to do the uploader endpoint, and it works perfectly. However tauri won't be able to actually download the files as they are on a private github repo

Describe the solution you'd like

Be able to provide custom headers into the tauri uploader config

Alternatives considered

Adding a proxy on that cloudflare worker

Additional context

No response

@ghostdevv
Copy link
Author

Amazing thank you sm @lucasfernog

Is there any documentation on how to use this?

@lucasfernog
Copy link
Member

lucasfernog commented Apr 22, 2022

@ghostdevv add this to your Cargo.toml:

[patch.crates-io]
tauri = { git = "https://github.com/tauri-apps/tauri" }
tauri-build = { git = "https://github.com/tauri-apps/tauri" }

You'll need to remove useBootstrapper field from your tauri.conf.json as the next release will remove that.

If you're using the Tauri CLI, you need to either build it from source or use Cargo directly.

  • Using the Rust CLI it from source
cargo install --git https://github.com/tauri-apps/tauri tauri-cli

cargo tauri dev
cargo tauri build
  • Using the Node.js CLI from source
git clone https://github.com/tauri-apps/tauri
cd tauri/tooling/cli/node
yarn
yarn build

node /path/to/tauri/tooling/cli/node/tauri.js dev
node /path/to/tauri/tooling/cli/node/tauri.js build
  • Using Cargo directly
cd src-tauri

cargo run --no-default-features # instead of tauri dev
cargo build # instead of tauri build - won't bundle your app though

If you're using the Tauri API, you might need to use the next version.

git clone https://github.com/tauri-apps/tauri
cd tauri/tooling/api
yarn
yarn build
  • Linking using yarn link:
cd dist
yarn link
cd /path/to/your/project
yarn link @tauri-apps/api
  • Alternatively, you can change your package.json to use the folder as a dependency:
{
  "dependencies": {
    "@tauri-apps/api": "/path/to/tauri/tooling/api/dist"
  }
}

@ghostdevv
Copy link
Author

Awesome, but how do I use this new feature? 🤔

@lucasfernog
Copy link
Member

You'll need to manually run the updater:

fn main() {
  tauri::Builder::default().setup(|app| {
    let handle = app.handle();
    tauri::async_runtime::spawn(async move {
      match handle
        .updater()
        .header("your-header", "value")
        .unwrap()
        .check()
        .await
      {
        Ok(update) => {
          update.download_and_install().await; // TODO: handle possible error
        }
        Err(e) => {
          println!("ERROR: {}", e);
        }
      }
    });
    Ok(())
  });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants