mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
fix: restore proxy config backwards compatibility with 0.x (#5097)
* fix: restore proxy config backwards compatibility with 0.x * Formatting Co-authored-by: Patrick Petrovic <patrick@Air-de-Patrick.lan> Co-authored-by: Jay <jasonsaayman@gmail.com>
This commit is contained in:
@@ -51,7 +51,7 @@ function dispatchBeforeRedirect(options) {
|
||||
* If the proxy or config afterRedirects functions are defined, call them with the options
|
||||
*
|
||||
* @param {http.ClientRequestArgs} options
|
||||
* @param {AxiosProxyConfig} configProxy
|
||||
* @param {AxiosProxyConfig} configProxy configuration from Axios options object
|
||||
* @param {string} location
|
||||
*
|
||||
* @returns {http.ClientRequestArgs}
|
||||
@@ -82,13 +82,14 @@ function setProxy(options, configProxy, location) {
|
||||
}
|
||||
|
||||
options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
|
||||
options.hostname = proxy.hostname;
|
||||
const proxyHost = proxy.hostname || proxy.host;
|
||||
options.hostname = proxyHost;
|
||||
// Replace 'host' since options is not a URL object
|
||||
options.host = proxy.hostname;
|
||||
options.host = proxyHost;
|
||||
options.port = proxy.port;
|
||||
options.path = location;
|
||||
if (proxy.protocol) {
|
||||
options.protocol = proxy.protocol;
|
||||
options.protocol = proxy.protocol.includes(':') ? proxy.protocol : `${proxy.protocol}:`;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,3 +587,5 @@ export default function httpAdapter(config) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export const __setProxy = setProxy;
|
||||
Reference in New Issue
Block a user