Last active
September 6, 2018 13:46
-
-
Save guillaumegarcia13/403b9e3a2cacfe05a5155e71dbee6768 to your computer and use it in GitHub Desktop.
Debug node.js requests with Fiddler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Adapted from: https://weblogs.asp.net/dixin/use-fiddler-with-node-js | |
/* Usage: | |
import { Fiddler } from './../src/helpers/fiddler'; | |
... | |
Fiddler.proxyRequests(); | |
*/ | |
import * as url from 'url'; | |
import * as http from 'http'; | |
const proxy = { | |
protocol: 'http:', | |
hostname: '127.0.0.1', | |
port : 8888, | |
}; | |
export class Fiddler { | |
public static proxyRequests(): void { | |
const proxyUrl = url.format(proxy); | |
process.env.http_proxy = proxyUrl; | |
process.env.https_proxy = proxyUrl; | |
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; | |
} | |
public static unproxyRequests(): void { | |
process.env.http_proxy = ''; | |
process.env.https_proxy = ''; | |
process.env.NODE_TLS_REJECT_UNAUTHORIZED = ''; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment