Proxy-Authorization header not working in Chromium
See original GitHub issueHello there, thanks for this great project.
I’m having trouble making requests though a proxy. Consider the following snippet:
import asyncio
from playwright import async_playwright
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch(
proxy={
"server": "PROXY_URL",
"username": "PROXY_APIKEY",
"password": "",
},
)
context = await browser.newContext(ignoreHTTPSErrors=True)
page = await context.newPage()
await page.goto("https://httpbin.org/ip")
print(await page.content())
await page.screenshot(path="ip_address.png")
await browser.close()
if __name__ == "__main__":
asyncio.run(main())
If I run it, I get:
$ DEBUG=pw:api python proxy.py
pw:api navigating to "https://httpbin.org/ip", waiting until "load" +0ms
pw:api navigated to "https://httpbin.org/ip" +1s
pw:api "load" event fired +7ms
pw:api "domcontentloaded" event fired +8ms
<html><head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">Internal Server Error</pre></body></html>
I can confirm the proxy URL and credentials are correct with cURL (the resulting IP address is not my own, as expected):
$ curl --insecure --proxy $PROXY_URL --proxy-user $PROXY_APIKEY: https://httpbin.org/ip
{
"origin": "xxx.xxx.xxx.xxx"
}
Could this be caused by the fact that the proxy server expects an empty password and Playwright sends some default value? For the record, I’m using Python 3.8.2 and Playwright 0.171.1 on GNU/Linux.
Looking forward to your answers, thanks again for the hard work.
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Regarding "Proxy-Authorization" header in chrome ...
I need to use "Proxy-Authorization" header in "onBeforeSendHeaders" event. but in documentation I see that this Header is currently not provided.
Read more >Allow setting Proxy-Authorization in chrome.webRequest API
It should be possible to set the Proxy-Authorization header in the chrome.webRequest API. chrome.webRequest. ... proxyAuthValue}); // Facing problem here
Read more >Chrome not setting Proxy-Authorization header while testing ...
Hi all,I'm doing testing from API Explorer in Portal. I have a swagger file which has apikey,apikeysecret and Proxy-Authorization passed as ...
Read more >Refused to set unsafe header "Proxy-Authorization" Chrome
enter image description here. We're having the same problem. I'm using axios inside electron it seems that axios is trying to override the ......
Read more >Why does Chrome not allow the modification of these headers ...
Proxy-AuthorizationThe HTTP Proxy-Authorization request header contains the credentials to authenticate a user agent to a proxy server, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, thanks for looking into this.
The proxy provider has instructed me to manually set the
Proxy-Authorization
header (the article is about Puppeteer, I suppose the concepts should still apply). Unfortunately, I’m still having issues, even with a local proxy (mitmproxy --proxyauth "user:pass"
):What seems strange to me is that I’m also having the same issue with plain Playwright:
Is there a chance this might be an upstream issue that should be solved in https://github.com/microsoft/playwright instead?
Closing as per above!