Skip to content

Commit

Permalink
fix(proxy) - explanations (ccxt#22348)
Browse files Browse the repository at this point in the history
* fix(proxy) - explanation to users

* minor

* minor

* Update Exchange.ts

[ci skip]
  • Loading branch information
Travis CI authored and DelAnt committed May 10, 2024
1 parent 343f82a commit 73e4419
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions dist/ccxt.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8029,6 +8029,10 @@ class Exchange {
}
setProxyAgents(httpProxy, httpsProxy, socksProxy) {
let chosenAgent = undefined;
// in browser-side, proxy modules are not supported in 'fetch/ws' methods
if (!isNode && (httpProxy || httpsProxy || socksProxy)) {
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' - proxies in browser-side projects are not supported. You have several choices: [A] Use `exchange.proxyUrl` property to redirect requests through local/remote cors-proxy server (find sample file named "sample-local-proxy-server-with-cors" in https://github.com/ccxt/ccxt/tree/master/examples/ folder, which can be used for REST requests only) [B] override `exchange.fetch` && `exchange.watch` methods to send requests through your custom proxy');
}
if (httpProxy) {
if (this.httpProxyAgentModule === undefined) {
throw new _errors_js__WEBPACK_IMPORTED_MODULE_3__.NotSupported(this.id + ' you need to load JS proxy modules with `.loadProxyModules()` method at first to use proxies');
Expand Down
2 changes: 1 addition & 1 deletion dist/ccxt.browser.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions dist/cjs/src/base/Exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,10 @@ class Exchange {
}
setProxyAgents(httpProxy, httpsProxy, socksProxy) {
let chosenAgent = undefined;
// in browser-side, proxy modules are not supported in 'fetch/ws' methods
if (!isNode && (httpProxy || httpsProxy || socksProxy)) {
throw new errors.NotSupported(this.id + ' - proxies in browser-side projects are not supported. You have several choices: [A] Use `exchange.proxyUrl` property to redirect requests through local/remote cors-proxy server (find sample file named "sample-local-proxy-server-with-cors" in https://github.com/ccxt/ccxt/tree/master/examples/ folder, which can be used for REST requests only) [B] override `exchange.fetch` && `exchange.watch` methods to send requests through your custom proxy');
}
if (httpProxy) {
if (this.httpProxyAgentModule === undefined) {
throw new errors.NotSupported(this.id + ' you need to load JS proxy modules with `.loadProxyModules()` method at first to use proxies');
Expand Down
4 changes: 4 additions & 0 deletions js/src/base/Exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,10 @@ export default class Exchange {
}
setProxyAgents(httpProxy, httpsProxy, socksProxy) {
let chosenAgent = undefined;
// in browser-side, proxy modules are not supported in 'fetch/ws' methods
if (!isNode && (httpProxy || httpsProxy || socksProxy)) {
throw new NotSupported(this.id + ' - proxies in browser-side projects are not supported. You have several choices: [A] Use `exchange.proxyUrl` property to redirect requests through local/remote cors-proxy server (find sample file named "sample-local-proxy-server-with-cors" in https://github.com/ccxt/ccxt/tree/master/examples/ folder, which can be used for REST requests only) [B] override `exchange.fetch` && `exchange.watch` methods to send requests through your custom proxy');
}
if (httpProxy) {
if (this.httpProxyAgentModule === undefined) {
throw new NotSupported(this.id + ' you need to load JS proxy modules with `.loadProxyModules()` method at first to use proxies');
Expand Down

0 comments on commit 73e4419

Please sign in to comment.