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
When using ClientRequestInterceptor with ProxyAgent, it ends with error
TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
at new ClientRequest (node:_http_client:183:11)
at new _NodeClientRequest (/home/indrek/service/node_modules/@mswjs/interceptors/lib/node/chunk-SXGRMPXP.js:226:5)
at interceptorsHttpRequest (/home/indrek/service/node_modules/@mswjs/interceptors/lib/node/chunk-SXGRMPXP.js:850:12)
at /home/indrek/service/node_modules/node-fetch/lib/index.js:1478:15
at new Promise (<anonymous>)
at fetch (/home/indrek/service/node_modules/node-fetch/lib/index.js:1447:9)
at Generator.next (<anonymous>)
Code is here:
import { ClientRequestInterceptor } from '@mswjs/interceptors/ClientRequest';
import fetch from 'node-fetch';
import { ProxyAgent } from 'proxy-agent';
async execute() {
const interceptor = new ClientRequestInterceptor();
interceptor.apply();
await fetch('https://google.com', {
agent: new ProxyAgent(), // ALL_PROXY=http://127.0.0.1:3000
});
interceptor.dispose();
}
At the first glance, the issue is happening because the request-making module (http or https) is bound to the initial request when using Interceptors. I assume during proxying, since you are switching protocols, the interceptor attempts to perform the proxied request using the wrong request module for some reason.
In theory, that shouldn't happen because the request originates from proxy-agent, we aren't constructing them internally (unless the request is bypassed, which I believe is precisely your use case).
When using ClientRequestInterceptor with ProxyAgent, it ends with error
Code is here:
Using packages:
Is there anything to configure to make it work with proxy?
The text was updated successfully, but these errors were encountered: