Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

338
Views
Chrome extension proxy authentication

I've got problem in proxy authentication using chrome extension (due to problems with v3 my code is based on manifest v2). The connection works using the following curl command:

curl -v -x https://11.111.11.111:222 https://www.google.com/ --proxy-header "proxy-authorization: Basic abc" --proxy-insecure

And I tried to implement it in extension. Here's what I have in background.js file:

chrome.runtime.onStartup.addListener(() => {
    const config = {
            mode: 'fixed_servers',
            rules: {
                singleProxy: {
                    host: '11.111.11.111',
                    port: 222,
                    scheme: 'https',
                },
            },
        }

        chrome.proxy.settings.set({ value: config, scope: 'regular' })
})

chrome.webRequest.onBeforeSendHeaders.addListener(
    (details) => {
        const requestHeaders = details.requestHeaders || []
        requestHeaders.push({
            name: 'proxy-authorization',
            value: 'Basic abc',
        })

        return { requestHeaders }
    },
    { urls: ['<all_urls>'] },
    ['blocking', 'requestHeaders', 'extraHeaders']
)

chrome.webRequest.onSendHeaders.addListener(
    (details) => {
        console.log('sending', details)
        return details
    },
    { urls: ['<all_urls>'] },
    ['requestHeaders', 'extraHeaders']
)

I have the following permissions in manifest.json:

"permissions": [
        "cookies",
        "storage",
        "tabs",
        "activeTab",
        "proxy",
        "webRequest",
        "webRequestBlocking",
        "<all_urls>"
    ]

And these are the headers that are printed in onSendHeaders function:

enter image description here

You see that proxy-authorization header is present. But I get ERR_PROXY_CERTIFICATE_INVALID while trying to browse any page. Proxy headers should be set in a different way? Because I use --proxy-header flag in the curl command, not --header.

PS. I tried using the method that is mentioned many times:

chrome.webRequest.onAuthRequired.addListener(function(details, callbackFn) {
    callbackFn({
        authCredentials: { username: username, password: password }
    });
},{urls: ["<all_urls>"]},['asyncBlocking']);

too, but this function is never called (I put console.log inside).

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!