reqwest
reqwest copied to clipboard
Relative URL without base should be allowed for WASM target
I am trying to use reqwest for creating in-browser request for my WASM application.
But reqwest only accepts full URL for making requests. My web app and resource I'm trying to get is on the same host. When I try to create relative URL, it returns ParseError::RelativeUrlWithoutBase instead.
I think this limitation makes reqwest not suitable for web frontend development for some cases. reqwest should accept relative URLs for WASM target.
Seems like it is an inherent limitation on rust-url crate. Any way to circumvent?
The same problem with me! I use window.location.origin to walk around this error.
pub fn base_url() -> String {
web_sys::window().unwrap().location().origin().unwrap()
}
let url = base_url() + "the relative path".