No-code automation platform connecting 6,000+ apps. Use Zapier Code steps to route HTTP requests through KnoxProxy for proxied web scraping, API polling, and data enrichment workflows.
Log in to Zapier and click "Create Zap". Add your trigger (e.g., Schedule, Webhook, or any app trigger).
Click "+" to add an action. Search for "Code by Zapier" and select "Run JavaScript".
Add input fields for proxy_url and target_url. Set proxy_url to your KnoxProxy gateway URL.
proxy_url: http://USER:PASS@gw.knoxproxy.com:7000
target_url: https://httpbin.org/ipIn the Code editor, write a fetch request using the proxy URL via the https-proxy-agent pattern.
Modify the proxy username to target a specific country.
http://USER-country-gb:PASS@gw.knoxproxy.com:7000Click "Test step" to verify the proxied response. Review the output and turn on the Zap.
// Zapier Code by Zapier - Run JavaScript
// Input Data: proxy_url, target_url
const proxyUrl = inputData.proxy_url;
const targetUrl = inputData.target_url;
// Parse proxy URL
const url = new URL(proxyUrl);
const proxyHost = url.hostname;
const proxyPort = url.port;
const proxyAuth = Buffer.from(
`${url.username}:${url.password}`
).toString('base64');
const http = require('http');
const https = require('https');
const response = await new Promise((resolve, reject) => {
const proxyReq = http.request({
host: proxyHost,
port: proxyPort,
method: 'CONNECT',
path: new URL(targetUrl).host + ':443',
headers: {
'Proxy-Authorization': `Basic ${proxyAuth}`,
},
});
proxyReq.on('connect', (res, socket) => {
const req = https.request(
targetUrl,
{ socket, agent: false },
(res) => {
let data = '';
res.on('data', (chunk) => (data += chunk));
res.on('end', () => resolve(data));
}
);
req.end();
});
proxyReq.on('error', reject);
proxyReq.end();
});
output = { body: response };Each Zap run gets a new IP automatically. For sticky sessions within a multi-step Zap, use USER-session-{zapRunId} as the proxy username.
| Problem | Fix |
|---|---|
| Error: connect ECONNREFUSED | Verify gw.knoxproxy.com:7000 is correct. Ensure your KnoxProxy plan allows cloud platform IPs. |
| Output is empty or undefined | Ensure the last line sets output = { body: response }. Zapier requires the output variable. |
| StepError: Code timed out after 30s | Simplify the request or target a faster endpoint. Zapier Code steps have a 30s limit on lower plans. |
USER-country-de-city-berlin-session-profile07Order matters -- geo flags before the session flag. The session name is free text; use the profile ID so the mapping is self-documenting. Password stays as issued; no flags belong there. HTTP on :7000, SOCKS5 on :7001, same credentials.
The Webhooks by Zapier action does not support proxy fields. You need a Code by Zapier step to route through a proxy.
Code by Zapier is available on Professional plans and above. Free and Starter plans do not include it.
Use Zapier Secret (inputData.secret) to store your password, then reference it in the Code step instead of hardcoding.
Yes. Use a Looping by Zapier step to iterate over URLs, each routed through KnoxProxy via the Code step.
Free trial on rotating residential -- 3 minutes setup, no credit card.