Skip to content

Commit

Permalink
Fix http agent proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyxiao committed Oct 11, 2023
1 parent 2912c59 commit 6b67d37
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion apps/app-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@usevenice/integration-yodlee": "workspace:*",
"@usevenice/util": "workspace:*",
"chokidar": "3.5.3",
"cross-fetch": "3.1.5",
"cross-fetch": "4.0.0",
"execa": "6.1.0",
"find-config": "1.0.0",
"read-file-safe": "1.0.10",
Expand Down
12 changes: 11 additions & 1 deletion apps/app-config/register.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,22 @@ if (process.env['SILENT']) {

console.log('[Dep] app-config/register.node')

implementProxyFn($getFetchFn, () => globalThis.fetch ?? crossFetch, {
// Prefer crossfetch for agent aka tunneling support
// TODO: Fix me by switchig to the undici ProxyAgent.
// @see https://undici.nodejs.org/#/docs/api/ProxyAgent
// And https://github.com/nodejs/undici/issues/1489
implementProxyFn($getFetchFn, () => crossFetch ?? globalThis.fetch, {
replaceExisting: true,
})

implementProxyFn(
$makeProxyAgent,
(input) => {
if (globalThis.fetch !== crossFetch) {
console.warn(
'[proxy] Using proxy agent with non-polyfilled fetch may not work',
)
}
// Seems that the default value get overwritten by explicit undefined
// value from envkey. Here we try to account for that
// Would be nice if such hack is not required.
Expand Down
34 changes: 27 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6b67d37

Please sign in to comment.