Open ufoscout opened 3 years ago
I have the same issue using Yew frontend with Trunk proxy, is there a work around ?
I'm interested in the same thing. It sounds like #988 would solve this though, as the issue isn't specific to WASM.
I think a workaround would use client-side JS to get the current base URL and pass it into the WASM function, then use join
to combine it with the relative URL.
I think the best way to handle this is to make requests using the gloo_net API, which is a wrapper around the fetch API. It isn't isomorphic to native Rust however, so this can be a pain in applications where that matters. I usually solve for this by leveraging conditional compilation. Come to think of it, now that fetch is in NodeJS 18, I think it might work fine on the backend in that instance.
I am trying to use
reqwest
to call my backend from a Yew-based WASM frontend running in the browser.HTTP calls to the backend are typically performed by a frontend application using relative URLs; anyway, this is not possible with
reqwest
as every attempt to send a call with a relative URL produces aRelativeUrlWithoutBase
error.This problem makes
reqwest
unsuitable for every rust frontend framework.This issue is closely related to #988, but #988 is quite generic while this one aims for a specific solution for WASM in the browser.