Proxy
In this article we’ll explore the possiblity of using a custom URI scheme protocol in Tauri to proxy requests. And as an added bonus we’ll also look at how you can add a ServiceWorker to effectively reroute any request to your own handlers.
As always, this feature only works in your apps webviews as it does not get registered to the system, just to your webviews.
When you’re dealing with HTTP requests in Rust the most popular library used is reqwest.
Using a ServiceWorker in the frontend portion of the project you can reroute any requests sent out from your app to your schema handler.
Why would you do it? Admittedly it’s a fairly niche functionality, but I’ve used it for an extension system in a web capable project. I can set up requests to my remotely running API server, then user the ServiceWorker to reroute those requests to my scheme handler only when running in the Tauri app version, which instead of fetching the extension from the API can check locally for the extensions zip archive to retrieve assets.