Closed yamauchi-nttcw closed 1 month ago
Are you running the WASM in a browser? reqwest makes use of the fetch
method, which uses the browser's ability to handle TLS connections.
Hi @seanmonstar, thank you for the reply.
Yes, we expect it to be compiled to WASM and run in a browser. To rephrase what you just mentioned, we should be able to connect these servers over SSL since Reqwest utilizes the Fetch API to handle TLS connections, provided we properly configure both the frontend and backend😏?
Would you also recommend Reqwest crate when targeting wasm32-unknown-unknown? Or you suggest Reqwest-wasm instead?
Best
The reqwest crate is meant to work for wasm targets.
I've never heard of reqwest-wasm before. I wouldn't be able to recommend it myself.
I seem to need a little bit more research and experimentation to figure out how I implement SSL connection with this crate...!
Reqwest-wasm can be found in the following URL: https://docs.rs/reqwest-wasm/0.11.16/wasm32-unknown-unknown/reqwest_wasm/index.html Please have a look if you are interested.
I am curious about the state in the document saying "Some of the features are disabled in WASM:tls, cookie, blocking". Does this not mean "Reqwest is meant to work for WASM application, but not supported to work with TLS"?
As I mentioned, on wasm targets reqwest will use fetch
from the browser. You can load your page in the browser and open a console and try using fetch
, and if it's not working, you likely have an issue with your server.
That line in the docs is meant that you can't use the types in reqwest::tls
to customize how the connection is made.
Hi,
Our team is trying to build a web application that utilizes Axum for the backend, Yew for the frontend, and SQLx for middleware. We have been struggling with establishing an SSL connection between our frontend and backend through Reqwest, especially since our application runs on WASM. (Please note that we successfully built an application that communicates via HTTP. Thank you for your work!)
After dozens of days of research, we feel that Reqwest targeting "wasm32-unknown-unknown" does not currently support establishing an SSL connection because the documentation states, "Some of the features are disabled in WASM." (Reference: https://docs.rs/reqwest/latest/reqwest/#wasm)
Does Reqwest actually support SSL for applications compiled to WASM, or is this still under development? By the way, the following code is something we have tried so far:
let response = reqwest::Client::new() .post(url) .json(&signup_data) .send() .await?; if response.status().is_success() { Ok(()) } else { let status_code = response.status().as_str().to_string(); let message = response.text().await?; Err(ApiError::Any(status_code, message).into()) }
We have also come across "reqwest-wasm," but I'm not entirely sure about the differences between this and the original Reqwest crate.
I would greatly appreciate any information you could provide regarding Reqwest(or Reqwest-wasm crate) for WASM.
Thank you!