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

[native fetch] fallback to native fetch doesn't support proxy agent #22353

Open
Johann-S opened this issue May 2, 2024 · 3 comments
Open

[native fetch] fallback to native fetch doesn't support proxy agent #22353

Johann-S opened this issue May 2, 2024 · 3 comments
Assignees

Comments

@Johann-S
Copy link
Contributor

Johann-S commented May 2, 2024

Operating System

All

Programming Languages

JavaScript

CCXT Version

Latest

Description

Currently if ccxt doesn't find node-fetch it use native fetch as a fallback here: https://github.com/ccxt/ccxt/blob/master/ts/src/base/Exchange.ts#L1166

unfortunately native fetch doesn't support proxy agent because it follow the original implementation from web browsers 😟

my question is, why not bundle node-fetch inside ccxt and avoid using an incomplete fallback? Or at least I think it should be added in the documentation?

@ttodua
Copy link
Member

ttodua commented May 2, 2024

in browsers, proxies are not supported, even with node-fetch (https://www.google.com/search?q=node-fetch+proxy+support+in+browser). That's a security feature in browsers not to allow proxy within fetch.

edit: ah, I think I misunderstood. so, you use the bundle in backend, right? hm, seems a valid point, if fallback is used. we will look into this and post an update.

@ttodua
Copy link
Member

ttodua commented May 2, 2024

can you please mention exactly which bunder do you use or even it would be nice if you share a simplified project (with tsconfig/package.json) so we would use the same bundling process to reproduce the problem.

@ttodua ttodua self-assigned this May 2, 2024
@Johann-S
Copy link
Contributor Author

Johann-S commented May 2, 2024

With node-fetch you can use an https proxy agent using the agent property (https://www.npmjs.com/package/node-fetch#custom-agent), that's what ccxt is doing currently https://github.com/ccxt/ccxt/blob/master/ts/src/base/Exchange.ts#L1195.

I'm using webpack latest version.

Simplified project: fetch-test.zip

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

2 participants