Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Disable proxy when useApifyProxy: false is used in proxy conf (#750)

Ondra Urbancaaa6b86cb9f
diff --git a/src/proxy_configuration.js b/src/proxy_configuration.js
index 3631a7480..681b3e28a 100644
--- a/src/proxy_configuration.js
+++ b/src/proxy_configuration.js
@@ -513,13 +513,27 @@ export class ProxyConfiguration {
* })
*
* ```
+ *
+ * For compatibility with existing Actor Input UI (Input Schema), this function
+ * returns `undefined` when the following object is passed as `proxyConfigurationOptions`.
+ *
+ * ```
+ * { useApifyProxy: false }
+ * ```
+ *
* @param {ProxyConfigurationOptions} [proxyConfigurationOptions]
-* @returns {Promise<ProxyConfiguration>}
+* @returns {Promise<?ProxyConfiguration>}
* @memberof module:Apify
* @name createProxyConfiguration
* @function
*/
-export const createProxyConfiguration = async (proxyConfigurationOptions) => {
+export const createProxyConfiguration = async (proxyConfigurationOptions = {}) => {
+ // Compatibility fix for Input UI where proxy: None returns { useApifyProxy: false }
+ // Without this, it would cause proxy to use the zero config / auto mode.
+ const dontUseApifyProxy = proxyConfigurationOptions.useApifyProxy === false;
+ const dontUseCustomProxies = !proxyConfigurationOptions.proxyUrls;
+ if (dontUseApifyProxy && dontUseCustomProxies) return undefined;
+
const proxyConfiguration = new ProxyConfiguration(proxyConfigurationOptions);
await proxyConfiguration.initialize();