#Middleware server for website-based app

15 messages · Page 1 of 1 (latest)

lofty lynx
#

Is there a way to make the requests from a tauri app connected to a site route through some kind of middleware before reaching the site?

By site-based app, I mean one that literally just connects to a site like a browser.

lofty lynx
#

I guess I could try to find whatever internal module does the browsing stuff and manually implement that but not sure if it's the best approach

tardy widget
lofty lynx
#

Instead of the usual file path

tardy widget
quasi compass
#

It sounds to me like the question is about whether Tauri can intercept the network requests of an arbitrary page, then modify or drop them?

tardy widget
#

If that's what it is then a ServiceWorker is the solution, Tauri doesn't have handlers for all network traffic, but a ServiceWorker will catch literally every single piece of networking that happens in the webview and you can decide to do whatever you want with the request

quasi compass
#

Can a ServiceWorker represent the main content of the page?

lofty lynx
tardy widget
# quasi compass Can a ServiceWorker represent the main content of the page?

It needs something to initially load it, but once loaded it can do whatever you want (networking related), so if your index.html file loads the worker, then sends a request for another javascript file or something, the service worker can generate that javascript file for you if you want and you essentially have a fully on SSR solution (WASM optional) running entirely within the browser

tardy widget
# lofty lynx Ok so I can just use window builder for the site part, but how do I get the serv...

For external websites it can be tricky and I haven't investigated it too much. I think you just have to eval the relevant javascript into the window for it, but there are limitations on service workers from the webview side that it has to be loaded from the proper origin, and I'm not sure if the eval counts, and it'll struggle for any external sites that provide their own service worker implementations

This is why working with external content is difficult