DEV Community

Cover image for Using fiddler as Proxy for NPM, Maven, Gradle
Arjun Shetty
Arjun Shetty

Posted on • Edited on

Using fiddler as Proxy for NPM, Maven, Gradle

Usually downloading packages has been pain over corporate networks. One way is to switch to personal network now and then to download packages.
Here is a work around for this, use any proxy server providing your credentials. But thing is everytime I change my password I break my head to finally realize the packages are not downloading because of the old credentials in the proxy settings. This is how I get around this, using Fiddler.

Once you have downloaded fiddler, open fiddler and then under rules menu check Automatically Authenticate

Alt Text.

For NPM

Set using following commands

npm config set proxy http://localhost:8888/
npm config set https-proxy http://localhost:8888/
Enter fullscreen mode Exit fullscreen mode

OR

do this manually, open C:\Users\<user name>\.npmrc and set proxy to the port fiddler is running on like below

proxy=http://localhost:8888/
https-proxy=http://localhost:8888/
strict-ssl=false
Enter fullscreen mode Exit fullscreen mode

strict-ssl is set to false to ignore certificate validation, Use this with caution there are a lot packages that are malicious.
now try npm -i <packagename>

For MAVEN

Open C:\Users\<user name>\.m2\settings.xml and add this follwing section in settings node

<proxies>
    <proxy>
        <id>optional</id>
        <active>true</active>
        <protocol>http</protocol>
        <host>localhost</host>
        <port>8888</port>
        <nonProxyHosts></nonProxyHosts>
    </proxy>
    <proxy>
        <id>optional</id>
        <active>true</active>
        <protocol>https</protocol>
        <host>localhost</host>
        <port>8888</port>
        <nonProxyHosts></nonProxyHosts>
    </proxy>
</proxies>

Enter fullscreen mode Exit fullscreen mode

For GRADLE

Add this below properties in root folder of gradle.properties

systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=8888
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=8888
Enter fullscreen mode Exit fullscreen mode

Hope this Helps!

Originally Posted on Bitsmonkey
Photo by Jonathan on Unsplash

Top comments (0)