Skip to content

feat(proxy): add proxy support#193

Open
mattfeldhake wants to merge 8 commits intoemartech:mainfrom
mattfeldhake:main
Open

feat(proxy): add proxy support#193
mattfeldhake wants to merge 8 commits intoemartech:mainfrom
mattfeldhake:main

Conversation

@mattfeldhake
Copy link
Copy Markdown

@mattfeldhake mattfeldhake commented Mar 24, 2026

BREAKING CHANGE: uses proxy environment variables if available to connect through the proxy

Comment thread package.json Outdated
Comment thread README.md
- Domain suffixes: `.local`, `.internal.example.com`
- Comma-separated lists: `localhost,.local,internal.example.com`

Proxy detection uses the [`proxy-from-env`](https://www.npmjs.com/package/proxy-from-env) library, which follows standard proxy environment variable conventions.
Copy link
Copy Markdown
Collaborator

@SchroederSteffen SchroederSteffen Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that axios has proxy support out-of-the-box using proxy-from-env, what does this PR add other than being able to overwrite the env variables via parameters?
I would at least assume that's not a breaking change based on that?
Or does escher-request set any parameters that somehow disable axios' ootb support? Like http(s)Agent?
Can't really dig in as I'm OOO.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find. We do use http/sAgent to support keep alive. Perhaps we only use this new logic for that use case since it is already supported otherwise. I believe there is a known issue for keep alive.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The axios docs even mention that keepAlive is enabled by default since Node.js v19 and our lowest supported version is 20.
Maybe there is some potential for cleanup, but that's for another PR.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I only maintain this repository to keep its dependencies up-to-date, but didn't really write or touch the actual code myself.
So I'm not really sure how to judge this change...

Copy link
Copy Markdown
Member

@ettancos ettancos Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  axios.get('https://www.google.com', {
    httpsAgent: new HttpsProxyAgent('http://localhost:3128'),
  //  proxy: false
  })
❯ env HTTPS_PROXY=http://localhost:3128 node index.js
Request failed with status code 502

❯ env NO_PROXY=www.google.com HTTPS_PROXY=http://localhost:3128 node index.js
200 <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="de-AT"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/
  axios.get('https://www.google.com', {
    httpsAgent: new HttpsProxyAgent('http://localhost:3128'),
    proxy: false
  })
❯ env HTTPS_PROXY=http://localhost:3128 node index.js
200 <!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="de-AT"><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"><meta content="/images/branding/googleg/1x/

no_proxy itself is working apparently, but because the https is broken the internal proxy mechanism must be disabled, this is the core of the issue :/

axios/axios#5256
axios/axios#6320
axios/axios#7299

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

f0a947f generally disables axios' broken built-in support.
Not 100% sure if this is desired, though.

Comment thread src/request.ts Outdated
Comment thread src/request.ts
return new RequestWrapper(requestOptions, protocol, payload);
}

private getOptionsFor(method: string, path: string): ExtendedRequestOption {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment below about proxy: false

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SchroederSteffen SchroederSteffen changed the title feat(request): add proxy support feat(proxy): add proxy support Apr 20, 2026
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

Successfully merging this pull request may close these issues.

3 participants