Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol "https:" not supported. Expected "http:" #391

Closed
WhoisUnknown opened this issue Jul 12, 2023 · 2 comments
Closed

Protocol "https:" not supported. Expected "http:" #391

WhoisUnknown opened this issue Jul 12, 2023 · 2 comments

Comments

@WhoisUnknown
Copy link

WhoisUnknown commented Jul 12, 2023

Hello. Thanks for you work.

I migrate from version 0.12.7 to 0.23.0 and get an error when I use http proxy

node:_http_client:189
    throw new ERR_INVALID_PROTOCOL(protocol, expectedProtocol);
    ^

TypeError [ERR_INVALID_PROTOCOL]: Protocol "https:" not supported. Expected "http:"
    at new NodeError (node:internal\errors:399:5)
    at new ClientRequest (node:_http_client:189:11)
    at new _NodeClientRequest (folder\node_modules\@mswjs\interceptors\lib\node\chunk-4YIZAGXJ.js:146:5)
    at Object.<anonymous> (folder\node_modules\@mswjs\interceptors\lib\node\chunk-4YIZAGXJ.js:665:22)
    at Object.<anonymous> (folder\dist\scripts\test.js:58:7)
    at Module._compile (node:internal\modules\cjs\loader:1256:14)
    at Module._extensions..js (node:internal\modules\cjs\loader:1310:10)
    at Module.load (node:internal\modules\cjs\loader:1119:32)
    at Module._load (node:internal\modules\cjs\loader:960:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal\modules\run_main:81:12) {
  code: 'ERR_INVALID_PROTOCOL'
}

Node.js v18.16.1

I am using https-user-agent and http proxy to it.

Version 0.12.7 this worked with proxy correctly

I made demo repository https://github.com/WhoisUnknown/example-interseptor

@kettanaito
Copy link
Member

Hi, @WhoisUnknown.

The proxy URL you are constructing is not a valid URL in Node.js:

// node_modules/https-proxy-agent/dist/index.js@53
 this.proxy = typeof proxy === 'string' ? new URL(proxy) : proxy;

The https-proxy-agent throws an error regarding that:

TypeError [ERR_INVALID_URL]: Invalid URL
    at __node_internal_captureLargerStackTrace (node:internal/errors:490:5)
    at new NodeError (node:internal/errors:399:5)
    at URL.onParseError (node:internal/url:565:9)
    at new URL (node:internal/url:645:5)
    at HttpsProxyAgent (/node_modules/https-proxy-agent/src/index.ts:53:44)

Once I fix the URL, the protocol error surfaces again.

const resultUrlProxy = 'http://example.com'

This should be fixed by #515.

@nodify-at
Copy link

@kettanaito do you have a plan soon to merge and publish #515 ? We have also some issues with proxies and getting exact the same error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs help
Development

No branches or pull requests

3 participants