W3cubDocs

/Web Extensions

proxy

Use the proxy API to proxy web requests. You can use the proxy.onRequest event listener to intercept web requests, and return an object that describes whether and how to proxy them.

The advantage of the proxy.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's storage and networking APIs like dns).

Apart from this API, extensions can also use the browserSettings.proxyConfig property to configure global proxy settings.

Google Chrome provides an 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 Chrome proxy API, this API is only available through the browser namespace.

To use this API you need to have the "proxy" permission. Also, where you want to intercept requests, you also need host permission for the URLs of intercepted requests.

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.

Functions

Warning: You should not use these methods (proxy.register() or proxy.unregister()) to register and remove an extended Proxy Auto-Configuration (PAC) file. They were deprecated in Firefox 68 and removed in Firefox 71.

proxy.register()
Registers the given proxy script.
proxy.unregister()
Unregisters the proxy script.

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.

Example extensions

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
onError
No
No
60
55-71
?
No
No
?
?
60
55
?
?
?
onRequest
No
No
60
Before version 78, the tabId and windowId filter properties are ignored.
?
No
No
?
?
60
?
?
?
ProxyInfo
No
No
60
?
No
No
?
?
60
?
?
?
RequestDetails
No
No
60
?
No
No
?
?
60
?
?
?
register
No
No
56-71
55-71
?
No
No
?
?
56-79
55-79
?
?
?
settings
No
No
60
From version 88, the ftp setting has no effect because FTP is no longer supported (see bug 1626365).
?
No
No
?
?
No
?
?
?
unregister
No
No
56-71
?
No
No
?
?
56-79
?
?
?

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/proxy