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

Can't make a simple request using node's https #55

Open
OnkelTem opened this issue Jun 18, 2022 · 0 comments
Open

Can't make a simple request using node's https #55

OnkelTem opened this issue Jun 18, 2022 · 0 comments

Comments

@OnkelTem
Copy link

OnkelTem commented Jun 18, 2022

This is my code:

import https from 'https';
import 'global-agent/bootstrap';

// https://docs.aws.amazon.com/general/latest/gr/pol.html

const options = {
  hostname: 'docs.aws.amazon.com',
  port: 443,
  path: '/general/latest/gr/pol.html',
  method: 'GET',
};

const req = https.request(options, res => {
  console.log(`statusCode: ${res.statusCode}`);

  res.on('data', d => {
    process.stdout.write(d);
  });
});

req.on('error', error => {
  console.error(error);
});

req.end();

Which I run as:

$ GLOBAL_AGENT_HTTPS_PROXY='https://127.0.0.1:8000' npx ts-node get-regions.ts

And I get an error:

/projects/custom/hfl/composer/node_modules/global-agent/src/utilities/parseProxyUrl.js:22
    throw new UnexpectedStateError('Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be "http:".');
          ^
UnexpectedStateError: Unsupported `GLOBAL_AGENT.HTTP_PROXY` configuration value: URL protocol must be "http:".
    at parseProxyUrl (/projects/custom/hfl/composer/node_modules/global-agent/src/utilities/parseProxyUrl.js:22:11)
    at BoundHttpsProxyAgent.getUrlProxy (/projects/custom/hfl/composer/node_modules/global-agent/src/factories/createGlobalProxyAgent.js:117:14)
    at BoundHttpsProxyAgent.addRequest (/projects/custom/hfl/composer/node_modules/global-agent/src/classes/Agent.js:90:24)
    at new ClientRequest (node:_http_client:305:16)
    at originalMethod (node:https:353:10)
    at Object.request (/projects/custom/hfl/composer/node_modules/global-agent/src/utilities/bindHttpMethod.js:51:14)
    at Object.<anonymous> (/projects/custom/hfl/composer/get-regions.ts:13:19)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Module.m._compile (/projects/custom/hfl/composer/node_modules/ts-node/src/index.ts:1455:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1155:10) {
  code: 'UNEXPECTED_STATE_ERROR'
}

Node version: 16.14.0
OS: Linux
And it doesn't matter do I have a running proxy or not - the error is triggered before.

chrishg2001 pushed a commit to chrishg2001/global-agent that referenced this issue Aug 6, 2022
chrishg2001 pushed a commit to chrishg2001/global-agent that referenced this issue Aug 6, 2022
mathieudutour added a commit to raycast/global-agent that referenced this issue Dec 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant