Skip to content

[http][v2] http could not set the origin in header #1389

@AlphaLiu

Description

@AlphaLiu

Hello everyone,

I am studying to write a tauri app and today I upgraded my tauri http plugin from 2.0.0.beta7 to 2.0.0.beta8, then I found my code could not get the data from a site correctly. I need some helps, thank you very much.

Reproduction

import { fetch } from "@tauri-apps/plugin-http";

    fetch('http://localhost/GRAPARA.TXT', {
      headers: {
        origin: 'https://www.abc.com',
        cookie: 'test=123',
        host: 'myhost.com',
      },
    })
      .then(response => response.text())
      .then(result => console.log(result))
      .catch(error => console.log('error', error));

I captured the package in the server, and got the header that is

GET http://localhost/GRAPARA.TXT HTTP/1.1
user-agent: tauri-plugin-http
origin: http://localhost:1420/test
accept: */*
cookie: HFS_SID_=0.0392719367519021
host: localhost

it seems that the header I specified didn't been sent to server.
the http 2.0.0.beta8 would sent the origin: http://localhost:1420/test , but 2.0.0.beta7 would not. That made the server reject my request. HOW to resolve, please advise, thank you!

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 125.0.2535.67
    ✔ MSVC: Visual Studio Community 2022
    ✔ rustc: 1.77.2 (25ef9e3d8 2024-04-09)
    ✔ cargo: 1.77.2 (e52e36006 2024-03-26)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 22.2.0
    - pnpm: 9.1.2
    - yarn: 1.22.22
    - npm: 10.7.0
    - bun: 1.1.2

[-] Packages
    - tauri [RUST]: 2.0.0-beta.22
    - tauri-build [RUST]: 2.0.0-beta.17
    - wry [RUST]: 0.40.0
    - tao [RUST]: 0.28.0
    - tauri-cli [RUST]: 1.5.11
    - @tauri-apps/api [NPM]: 2.0.0-beta.13
    - @tauri-apps/cli [NPM]: 2.0.0-beta.20

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions