proxy
Use the proxy API to proxy web requests. You can use theproxy.onRequest
event listener to intercept web requests, and return an object that describes whether and how to proxy them.
The advantage of theproxy.onRequest
approach is that the code that implements your proxy policy runs in your extension's background script, so it gets full access to the WebExtension APIs available to your extension (including, for example, access to your extension'sstorage
and networking APIs likedns
).
Apart from this API, extensions can also use thebrowserSettings.proxyConfig
property to configure global proxy settings.
Note:Chrome, Edge, and Opera havean extension API also called "proxy" which is functionally similar to this API, in that extensions can use it to implement a proxying policy. However, the design of the Chrome API is completely different to this API. Because this API is incompatible with the Chromeproxy
API, this API is only available through thebrowser
namespace.
To use this API you need to have the "proxy"permission. Also, where you want to intercept requests, you also needhost permission for the URLs of intercepted requests.
The "proxy" permission requires"strict_min_version"
to be set to "91.1.0" or above. To use this permission, add or update the"browser_specific_settings"
key in yourmanifest.json to specify a minimum Firefox version. SeeSecuring the proxy API for Firefox add-ons for more information.
Note:The browser can make speculative connections, where it determines that a request to a URI may be coming soon. This type of connection does not provide valid tab information, so request details such astabId
,frameId
,parentFrameId
, etc. are inaccurate. These connections have awebRequest.ResourceType
ofspeculative
.
Types
proxy.ProxyInfo
Describes a proxy.
proxy.RequestDetails
Contains information about a web request that the browser is about to make.
Properties
proxy.settings
Get and set proxy settings.
Events
proxy.onError
Fired when the system encounters an error running the PAC script or the
onRequest
listener.proxy.onRequest
Fired when a web request is about to be made, giving the extension an opportunity to proxy it.