iTwin / itwinjs-core

Monorepo for iTwin.js Library
https://www.itwinjs.org
MIT License
583 stars 211 forks source link

Proxy support in Electron #5190

Open calebmshafer opened 1 year ago

calebmshafer commented 1 year ago

Is your feature request related to a problem? Please describe.

iTwin.js 2.x supported proxying all requests being sent by an iTwin.js Electron app using a configuration on the "Client" class. During the release of 3.0, that support was removed as all client shifted to be managed independently from each other and not have a low level base class they all derived.

However, being able to proxy is still a requirement for some application and their use case so we need to provide how an iTwin.js Electron app can use a proxy.

Describe the solution you'd like

Electron supports a command line argument way of setting up the proxy. This could be recommended way to launch the application when it is bundled and installed.

From a quick look, the main complication we will face is with proxying any of the calls going through the native code to fetch iModels. All other calls using the fetch APIs should be able to leverage the proxy.

Describe alternatives you've considered

One of the other options is to try and automate the proxy settings if there is a system wide proxy set already. Here's a potential example of it. https://evandontje.com/2020/04/02/automatic-system-proxy-configuration-for-electron-applications/

ben-polinsky commented 1 year ago

@calebmshafer we have two users with issues. For one, the proxy "workaround" works (using a separate client for hub access). For the other, this does not work or is not applicable - the user is facing a self signed certificate in chain error.

The first issue is simple enough to solve using command line options or even environment variables. In my testing, proxies are picked up when setting http_proxy/https_proxy in the environment.

The second issue is tougher because I have not been able to reproduce using proxies with self-signed certs. I am still looking into an environment to do so.