Submit a CAPTCHA solution with Axios

By solvethree2 min read

Solve with the Node.js SDK, then use Axios for the target request. Pass the successful proxy to HttpsProxyAgent and set proxy: false so Axios doesn't apply competing proxy configuration. Your application still supplies the form fields, CSRF value, and session cookies.

On this page

Install and configure the SDK

Use Node.js 22+ and install the dependencies with npm install axios https-proxy-agent https://solvethree.com/downloads/solvethree-sdk-0.1.0.tgz. The official SDK is distributed through that tarball URL; don't substitute an assumed npm registry package.

  • Set SOLVETHREE_API_KEY to your workspace API key. Run this code on the server and keep the key there.
  • Set SOLVETHREE_PROXY to the proxy URL used for both solving and submission.
  • Create an active profile for the target site in the console before solving. Supplying a hostname and action doesn't create one. See site profile setup.
  • Replace the example hostname, action, and login URL with your application's values. site is a hostname, not a full URL; the action must match the target operation.

Solve, then submit through the successful proxy

client.solve() creates the task and polls until it's ready or throws. The example then selects the original successful proxy with successfulProxy(input, result) and uses it for the Axios request.

Axios · explicit target proxy agent
// npm install axios https-proxy-agent and the official solvethree SDK tarball.
import axios from 'axios';
import { HttpsProxyAgent } from 'https-proxy-agent';
import { Solvethree, successfulProxy } from '@solvethree/sdk';
const client = new Solvethree({ apiKey: process.env.SOLVETHREE_API_KEY });
const input = { site: 'accounts.example.com', action: 'login', proxy: process.env.SOLVETHREE_PROXY };
const result = await client.solve(input);
const proxy = successfulProxy(input, result);
if (!proxy) throw new Error('No valid successful proxy');
const agent = new HttpsProxyAgent(proxy);
try {
  const response = await axios.post('https://accounts.example.com/login',
    new URLSearchParams({ 'g-recaptcha-response': result.solution.token }).toString(), {
      httpsAgent: agent, proxy: false, maxRedirects: 0, timeout: 30000,
      headers: { 'Content-Type': 'application/x-www-form-urlencoded',
        'User-Agent': result.solution.userAgent, 'sec-ch-ua': result.solution.secChUa },
      validateStatus: () => true,
    });
  console.log('Application HTTP status:', response.status);
  // Add the application's real form fields, CSRF value and session cookies.
} finally { agent.destroy(); }

httpsAgent routes the HTTPS target request through the selected proxy. proxy: false disables Axios's separate proxy configuration, leaving the agent in control. This configures the target request—not the SDK's connection to the solvethree API. The agent is destroyed when the request finishes or fails.

Keep the returned userAgent and secChUa values with that proxy. Don't replace them with unrelated browser headers when submitting the token.

Check the application response

The Axios call has a 30-second timeout and doesn't follow redirects. Because validateStatus accepts every HTTP status, inspect response.status and the response body yourself; an HTTP error response won't throw solely because of its status.

A ready task means a solution was generated, not that the target accepted it. Check the application's actual success condition rather than treating the logged HTTP status as proof of a successful login.

Run your first task.

Start with $5 in workspace credit.

Create a workspace