You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`pageOrReq` <[object](https://developer.mozilla.org/en-US/docs/Glossary/Object)> 'Page' or 'Request' object to set a proxy for.
21
21
-`proxy` <[string](https://developer.mozilla.org/en-US/docs/Glossary/String)|[object](https://developer.mozilla.org/en-US/docs/Glossary/Object)> Proxy to use in the current page.
22
22
* Begins with a protocol (e.g. http://, https://, socks://)
23
-
* In the case of [proxy per request](https://github.com/Cuadrix/puppeteer-page-proxy#proxy-per-request), this can be an object with optional properites for overriding requests:\
23
+
* In the case of [proxy per request](https://github.com/Cuadrix/puppeteer-page-proxy#proxy-per-request), this can be an object with optional properties for overriding requests:\
24
24
`url`, `method`, `postData`, `headers`\
25
-
See [request.continue](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#requestcontinueoverrides) for more info about the above properties.
25
+
See [httpRequest.continue](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#httprequestcontinueoverrides) for more info about the above properties.
@@ -38,26 +38,14 @@ See [request.continue](https://github.com/puppeteer/puppeteer/blob/master/docs/a
38
38
**NOTE:** By default this method expects a response in [JSON](https://en.wikipedia.org/wiki/JSON#Example) format and [JSON.parse](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse)'s it to a usable javascript object. To disable this functionality, set `isJSON` to `false`.
**NOTE:** It is necessary to set [page.setRequestInterception](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#pagesetrequestinterceptionvalue) to true when setting proxies per request, otherwise the function will fail.
92
+
**NOTE:** It is necessary to set [page.setRequestInterception](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagesetrequestinterceptionvalue) to true when setting proxies per request, otherwise the function will fail.
let data =awaituseProxy.lookup(page1); // Waits until done, 'then' continues
139
-
console.log(data.ip);
140
-
awaitpage1.goto(site);
101
+
// 1. Waits until done, 'then' continues
102
+
constdata=awaituseProxy.lookup(page1);
103
+
console.log(data.ip);
141
104
142
-
// 2
143
-
constpage2=awaitbrowser.newPage();
144
-
awaituseProxy(page2, proxy2);
145
-
useProxy.lookup(page2).then(data=> { // Executes and 'comes back' once done
146
-
console.log(data.ip);
147
-
});
148
-
awaitpage2.goto(site);
149
-
})();
105
+
// 2. Executes and 'comes back' once done
106
+
useProxy.lookup(page2).then(data=> {
107
+
console.log(data.ip);
108
+
});
109
+
```
110
+
In case of any [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) errors, use `--disable-web-security` launch flag:
111
+
```js
112
+
constbrowser=awaitpuppeteer.launch({
113
+
args: ['--disable-web-security']
114
+
});
150
115
```
151
116
152
117
## FAQ
@@ -156,7 +121,7 @@ It takes over the task of requesting content **from** the browser to do it inter
156
121
157
122
#### Why am I getting _"Request is already handled!"_?
158
123
159
-
This happens when there is an attempt to handle the same request more than once. An intercepted request is handled by either [request.abort](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#requestaborterrorcode), [request.continue](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#requestcontinueoverrides) or [request.respond](https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#requestrespondresponse) methods. Each of these methods 'send' the request to its destination. A request that has already reached its destination cannot be intercepted or handled.
124
+
This happens when there is an attempt to handle the same request more than once. An intercepted request is handled by either [httpRequest.abort](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#httprequestaborterrorcode), [httpRequest.continue](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#httprequestcontinueoverrides) or [httpRequest.respond](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#httprequestrespondresponse) methods. Each of these methods 'send' the request to its destination. A request that has already reached its destination cannot be intercepted or handled.
160
125
161
126
162
127
#### Why does the browser show _"Your connection to this site is not secure"_?
0 commit comments