Configure Karate’s HTTP Proxy in karate-config.js
Configure an HTTP forward proxy in karate-config.js with a URI and the supported proxy-account or bypass fields.
Karate exposes the forward proxy as an HTTP-client configuration value. In karate-config.js, configure it before returning the test configuration:
function fn() {
karate.configure('proxy', {
uri: 'http://proxy.example:8080',
nonProxyHosts: ['localhost', '*.internal.example']
});
return { baseUrl: 'https://service.example' };
}
The feature's request URL still comes from the service configuration. uri identifies the intermediary; the HTTP proxy list supplies public HTTP candidates for that value when the tested service permits such a route.
For an authenticated proxy, the configuration object also accepts username and password. Obtain them from the test environment's existing credential configuration. The API's own authorization is a separate request concern.
A single proxy URL can also be used where the object fields are unnecessary. Use the object when its account or nonProxyHosts policy is needed.
Keep wildcard patterns appropriate to Karate's supported bypass interface rather than copying a different client's NO_PROXY syntax without checking it.
Historical suggestions to switch between karate-apache and karate-jersey refer to older transport packaging. Select the API of the installed Karate version before changing dependencies to diagnose a proxy endpoint.