DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
19.37k stars 747 forks source link

`dx serve` build fails when using cookies feature on reqwest crate #2099

Closed Harjun751 closed 3 months ago

Harjun751 commented 3 months ago

Problem

As per title. Everything works fine until using a method provided only in the cookies feature. The project builds fine using cargo build

Error: 🚫 Serving project failed: error[E0599]: no method named `cookie_store` found for struct `ClientBuilder` in the current scope
--> src\main.rs:21:42
   |
21 |     let cli = reqwest::Client::builder().cookie_store(true).build().unwrap();
   |                                          ^^^^^^^^^^^^ method not found in `ClientBuilder`

My main.rs:

#![allow(non_snake_case)]
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
use dioxus::prelude::*;

fn main() {
    // launch the web app
    dioxus_web::launch(App);
}

// create a component that renders a div with the text "Hello, world!"
fn App(cx: Scope) -> Element {
    cx.render(rsx! {
        div {
            "Hello, world!"
        }
    })
}

async fn brokey(){
    let endpoint = format!("http://dinguswingus.com/dingus");
    let cli = reqwest::Client::builder().cookie_store(true).build().unwrap();

    cli.post(endpoint).send().await;
}

Steps To Reproduce

Steps to reproduce the behavior: Create a new demo project as usual, then add reqwests with cookies

Expected behavior

The build doesn't fail :(

Environment:

Questionnaire

ealmloff commented 3 months ago

cargo build will build an application that targets your current platform. cargo build --target wasm32-unknown-unknown will build an application that targets WASM (like dioxus web). reqwest. It looks like reqwest doesn't support cookies in wasm: https://github.com/seanmonstar/reqwest/pull/1449