-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
28 lines (23 loc) · 880 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { BatchInterceptor } from '@mswjs/interceptors';
// eslint-disable-next-line node/file-extension-in-import
import { ClientRequestInterceptor } from '@mswjs/interceptors/ClientRequest';
// eslint-disable-next-line node/file-extension-in-import
import { XMLHttpRequestInterceptor } from '@mswjs/interceptors/XMLHttpRequest';
import * as https from 'https';
import { HttpsProxyAgent } from 'https-proxy-agent';
const interceptor = new BatchInterceptor({
name: 'my-interceptor',
interceptors: [
new ClientRequestInterceptor(),
new XMLHttpRequestInterceptor(),
],
});
interceptor.apply();
interceptor.on('request', (req) => {
console.log(req);
});
const resultUrlProxy = 'http://name:password@ip:port';
const httpAgent = new HttpsProxyAgent(resultUrlProxy);
https.get('https://api.myip.com', { agent: httpAgent }, (res) => {
res.pipe(process.stdout);
});