Change behavior of resource fetching with plugin (Capacitor or Cordova)

Is it possible to change the behavior of how ionic fetches content using a plugin? For example, lets say I have an iframe with an src tag that contains a url type that ionic doesn’t understand. Is it possible to route that through a plugin that knows how to handle it?

any thoughts on this? We are trying to insert a “.onion” URL into a src tag for an iframe and wondering how we can pop the hood to handle that properly.

Yeah, you’re probably not going to be able to do this regardless of what tech you use.

.onion tlds are only accessible through TOR. Your standard stack is not going to be able to load these at all. It’s not a Capacitor or cordova limitation, it’s way more involved than that.

We’re aware that onion urls are not going through typical DNS resolution and that they also imply a different Transport layer. What we are asking is what exactly it will take to be able to modify Ionic’s behavior, plugin or otherwise, such that we can route traffic over a SOCKS5H proxy. I think functionality like this is useful for cases beyond tor, and we may have some extra cycles to be able to assist with this if we understand where and how this piece is implemented today. If this is handled below the Ionic layer, which libraries/technologies has the src attribute (or more generally DOM rendering) been delegated to?


Yes, our tech stack is already very Tor heavy, and we’re already building a Cordova/Capacitor plugin that can run the Tor proxy. We just want to know how to use it from more than just js.

On Capacitor 2, the WebViewClient is accessible, you can subclass it and replace default one with your own.
The WebViewClient is what returns the app resources and handles WebView navigation, so I think that should work for your use case.

1 Like

Thank you! We’ll take a look.