You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Question: How to use mockttp with Electron exes? #104
Hi @oswinbk, it depends on the Electron app. Somehow you need to configure the app to use your proxy settings and trust your CA certificate. For some apps, you can do that by trusting the CA certificate and configuring your proxy globally on your machine. For other apps, you might need to configure these settings inside the app itself, or to manually inject these settings in more complicated ways e.g. as HTTP Toolkit does here: https://github.com/httptoolkit/httptoolkit-server/blob/main/src/interceptors/electron.ts.
Hi @oswinbk, it depends on the Electron app. Somehow you need to configure the app to use your proxy settings and trust your CA certificate. For some apps, you can do that by trusting the CA certificate and configuring your proxy globally on your machine. For other apps, you might need to configure these settings inside the app itself, or to manually inject these settings in more complicated ways e.g. as HTTP Toolkit does here: https://github.com/httptoolkit/httptoolkit-server/blob/main/src/interceptors/electron.ts.
So is it possible to emulate what httptoolkit does with electron apps into a mockttp program?
HTTP Toolkit is a Mockttp program - it's an app built on top of Mockttp. Anything you can do with HTTP Toolkit can be done with Mockttp too, and all the code to do so is already open source.
That doesn't mean it's easy, and I'm afraid I can't help you write it in detail, I just don't have time, but the code linked above is literally the code HTTP Toolkit runs to do this, so you should be able to build on that to achieve this.
Activity
pimterry commentedon Sep 27, 2022
Hi @oswinbk, it depends on the Electron app. Somehow you need to configure the app to use your proxy settings and trust your CA certificate. For some apps, you can do that by trusting the CA certificate and configuring your proxy globally on your machine. For other apps, you might need to configure these settings inside the app itself, or to manually inject these settings in more complicated ways e.g. as HTTP Toolkit does here: https://github.com/httptoolkit/httptoolkit-server/blob/main/src/interceptors/electron.ts.
oswinkil-git commentedon Sep 27, 2022
So is it possible to emulate what httptoolkit does with electron apps into a mockttp program?
pimterry commentedon Sep 27, 2022
HTTP Toolkit is a Mockttp program - it's an app built on top of Mockttp. Anything you can do with HTTP Toolkit can be done with Mockttp too, and all the code to do so is already open source.
That doesn't mean it's easy, and I'm afraid I can't help you write it in detail, I just don't have time, but the code linked above is literally the code HTTP Toolkit runs to do this, so you should be able to build on that to achieve this.
oswinkil-git commentedon Sep 27, 2022
Thank you for the answer!
oswinkil-git commentedon Oct 5, 2022
Hi, I wanted to get some clarification on how https://github.com/httptoolkit/httptoolkit-server/blob/main/src/interceptors/terminal/fresh-terminal-interceptor.ts works. Does it just spawn a child process with its own environment, where the CA it uses is generated from mockttp?
pimterry commentedon Oct 5, 2022
Yes, exactly. All it's doing is launching a process with extra env vars, as set in getTerminalEnvVars. Some of those env vars do reference & inject extra files, e.g. the Java agent JAR, or the JS hook scripts, which all live in /overrides: https://github.com/httptoolkit/httptoolkit-server/tree/main/overrides