Compare commits

...

1 Commits

Author SHA1 Message Date
Gauthier
95ce4c5019 fix(proxy): apply all proxy settings to Axios 2025-06-24 10:50:22 +02:00
4 changed files with 19 additions and 9 deletions

View File

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

View File

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

View File

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

View File

@@ -56,12 +56,9 @@ export default async function createCustomProxyAgent(
: undefined;
try {
const proxyUrl =
(proxySettings.useSsl ? 'https://' : 'http://') +
proxySettings.hostname +
':' +
proxySettings.port;
const proxyUrl = `${proxySettings.useSsl ? 'https' : 'http'}://${
proxySettings.hostname
}:${proxySettings.port}`;
const proxyAgent = new ProxyAgent({
uri: proxyUrl,
token,
@@ -70,10 +67,17 @@ export default async function createCustomProxyAgent(
setGlobalDispatcher(proxyAgent.compose(noProxyInterceptor));
axios.defaults.httpAgent = new HttpProxyAgent(proxyUrl);
axios.defaults.httpsAgent = new HttpsProxyAgent(proxyUrl);
axios.defaults.httpAgent = new HttpProxyAgent(proxyUrl, {
headers: token ? { 'proxy-authorization': token } : undefined,
});
axios.defaults.httpsAgent = new HttpsProxyAgent(proxyUrl, {
headers: token ? { 'proxy-authorization': token } : undefined,
});
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.httpsAgent = false;
}