Chrome CDP Proxy Authentication: Handle Both Fetch Event Paths
Enable auth requests before navigation, continue ordinary paused requests and answer only the intended Proxy challenge with a bounded attempt policy.
On the relevant CDP session, register handlers before navigation, then call Fetch.enable with these parameters:
{"handleAuthRequests": true}| Event | Required response path |
|---|---|
| Fetch.requestPaused | continueRequest with that requestId when ordinary work should proceed |
| Fetch.authRequired | Inspect authChallenge, then continueWithAuth using the authentication event's requestId |
For the recognized intermediary, the auth parameters are:
{
"requestId": "REQUEST_ID_FROM_AUTH_EVENT",
"authChallengeResponse": {
"response": "ProvideCredentials",
"username": "PROXY_USERNAME",
"password": "PROXY_PASSWORD"
}
}Check authChallenge.source is Proxy and its origin is the intended challenger before loading the account from the credential source. A Server challenge follows another authentication policy.
Track allowed attempts per intercepted request; a repeated rejected challenge should receive CancelAuth, not another endless submission. Clear tracking on completion/session closure.
If the page hangs, inspect unresolved requestPaused events too. Authentication handling does not continue them automatically, and neither event path selects the browser's proxy route.