Skip to content

Instantly share code, notes, and snippets.

@guillaumegarcia13
Last active September 6, 2018 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillaumegarcia13/403b9e3a2cacfe05a5155e71dbee6768 to your computer and use it in GitHub Desktop.
Save guillaumegarcia13/403b9e3a2cacfe05a5155e71dbee6768 to your computer and use it in GitHub Desktop.
Debug node.js requests with Fiddler
/* 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