fix(proxy): apply all proxy settings to Axios (#1741)

This commit is contained in:
Gauthier
2025-06-25 16:40:24 +02:00
committed by GitHub
parent 0fd03f3848
commit b83367cbf2
4 changed files with 19 additions and 9 deletions

View File

@@ -37,6 +37,8 @@ class ExternalAPI {
...options.headers, ...options.headers,
}, },
}); });
this.axios.interceptors.request = axios.interceptors.request;
this.axios.interceptors.response = axios.interceptors.response;
if (options.rateLimit) { if (options.rateLimit) {
this.axios = rateLimit(this.axios, { this.axios = rateLimit(this.axios, {

View File

@@ -123,6 +123,8 @@ class TautulliAPI {
}${settings.urlBase ?? ''}`, }${settings.urlBase ?? ''}`,
params: { apikey: settings.apiKey }, params: { apikey: settings.apiKey },
}); });
this.axios.interceptors.request = axios.interceptors.request;
this.axios.interceptors.response = axios.interceptors.response;
} }
public async getInfo(): Promise<TautulliInfo> { public async getInfo(): Promise<TautulliInfo> {

View File

@@ -150,6 +150,8 @@ class ImageProxy {
baseURL: baseUrl, baseURL: baseUrl,
headers: options.headers, headers: options.headers,
}); });
this.axios.interceptors.request = axios.interceptors.request;
this.axios.interceptors.response = axios.interceptors.response;
if (options.rateLimitOptions) { if (options.rateLimitOptions) {
this.axios = rateLimit(this.axios, options.rateLimitOptions); this.axios = rateLimit(this.axios, options.rateLimitOptions);

View File

@@ -56,12 +56,9 @@ export default async function createCustomProxyAgent(
: undefined; : undefined;
try { try {
const proxyUrl = const proxyUrl = `${proxySettings.useSsl ? 'https' : 'http'}://${
(proxySettings.useSsl ? 'https://' : 'http://') + proxySettings.hostname
proxySettings.hostname + }:${proxySettings.port}`;
':' +
proxySettings.port;
const proxyAgent = new ProxyAgent({ const proxyAgent = new ProxyAgent({
uri: proxyUrl, uri: proxyUrl,
token, token,
@@ -70,10 +67,17 @@ export default async function createCustomProxyAgent(
setGlobalDispatcher(proxyAgent.compose(noProxyInterceptor)); setGlobalDispatcher(proxyAgent.compose(noProxyInterceptor));
axios.defaults.httpAgent = new HttpProxyAgent(proxyUrl); axios.defaults.httpAgent = new HttpProxyAgent(proxyUrl, {
axios.defaults.httpsAgent = new HttpsProxyAgent(proxyUrl); headers: token ? { 'proxy-authorization': token } : undefined,
});
axios.defaults.httpsAgent = new HttpsProxyAgent(proxyUrl, {
headers: token ? { 'proxy-authorization': token } : undefined,
});
axios.interceptors.request.use((config) => { axios.interceptors.request.use((config) => {
if (config.url && skipUrl(config.url)) { const url = config.baseURL
? new URL(config.baseURL + (config.url || ''))
: config.url;
if (url && skipUrl(url)) {
config.httpAgent = false; config.httpAgent = false;
config.httpsAgent = false; config.httpsAgent = false;
} }