In an async main-process function with an existing window, query the session that window actually uses:

const selectedSession = mainWindow.webContents.session;
const route = await selectedSession.resolveProxy('https://api.example/');

The current API returns a Promise resolving to a string. Await a pending setProxy operation before inspecting a configuration change.

The result is a URL-specific proxy decision. A hypothetical value could be:

PROXY proxy-a.example:8080; PROXY proxy-b.example:8080; DIRECT

That is an ordered candidate list in PAC-style syntax, rather than one hostname. DIRECT explicitly represents a direct candidate. Handle an empty result separately; do not silently treat every empty or unrecognized string as DIRECT.

Query the actual target URL because PAC and bypass decisions can differ by destination. Likewise, a window using a partitioned session need not have the same policy as session.defaultSession.

Proxy resolution can involve automatic-configuration work such as obtaining a PAC script. The returned choice still is not a completed request to the target website, a successful proxy login or proof of its public exit IP. Retain the session, URL and resolved candidates when comparing them with the subsequent request’s outcome.

متعلقہ مضامین