import { request as apiRequests } from '@playwright/test';

const api = await apiRequests.newContext({
  proxy: { server: 'http://proxy.example:8080' }
});

try {
  const response = await api.get('https://example.com/');
} finally {
  await api.dispose();
}

Pass proxy when you create a standalone APIRequestContext. For a public-proxy run, select an HTTP endpoint from the HTTP proxy list and replace the example proxy address; keep your intended API URL as the destination. This context owns its connection configuration and needs disposal after use.

A browser launch setting does not configure independently constructed API contexts. Playwright Test's built-in request fixture reads the relevant test configuration, but a helper calling newContext() creates another configuration boundary. If browser navigation works while the helper times out, find that call site and inspect the options it receives.

Routing is also separate from destination login. Proxy credentials authorize the intermediary. Website credentials and cookies authorize the target; a standalone context does not inherit browser cookies merely because the hostname matches. Browser-associated request contexts have their own documented cookie-sharing behavior.

Leave certificate verification enabled when selecting the route. ignoreHTTPSErrors changes validation, not which proxy this context uses.

Winndannde jowitiiɗe heen