How to listen to https endpoint with Yew & Trunk?

343 views Asked by At

I am trying to develop a web app, for oauth2 debugging I am required to have the web app respond to https, how can this be done developing with Yew?

Currently I am using:

trunk serve --proxy-backend=<backend-endpoint>

In order to serve.

1

There are 1 answers

3
Njuguna Mureithi On

You can use tunnelling through a HTTP tunnel which opens your dev server to the internet and has https. I can recommend you use Ngrok but there are way more services out there. Eg:

ngrok http 8080

You can combine it with something like cargo-make to add a new command.

use ngrok;

fn main() -> std::io::Result<()> {
    let tunnel = ngrok::builder()
        .http()
        .port(8080)
        .run()?;

    let public_url: url::Url = tunnel.http()?;

    Command::new("trunk")
            .arg("serve")
            .arg(format!("--proxy-backend={public_url}"))
            .output()
            .expect("failed to execute process")

    Ok(())
}