Skip to content

Commit

Permalink
Fix proxy conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz committed Jan 15, 2025
1 parent b6eb8de commit cda0351
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions server/core/helpers/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,14 @@ export function generateRequestStream (url: string, options: PeerTubeRequestOpti
}

export function getProxyAgent () {
if (!isProxyEnabled()) return {}
if (!isProxyEnabled()) {
return {
agent: { // Fix issue https://github.com/node-fetch/node-fetch/issues/1735 with Node 20
http: new http.Agent({ keepAlive: false }),
https: new https.Agent({ keepAlive: false })
}
}
}

const proxy = getProxy()

Expand Down Expand Up @@ -230,10 +237,6 @@ function buildGotOptions (options: PeerTubeRequestOptions): OptionsOfUnknownResp
return {
method: options.method,
dnsCache: true,
agent: { // Fix issue https://github.com/node-fetch/node-fetch/issues/1735 with Node 20
http: new http.Agent({ keepAlive: false }),
https: new https.Agent({ keepAlive: false })
},
timeout: {
request: options.timeout ?? REQUEST_TIMEOUTS.DEFAULT
},
Expand Down

0 comments on commit cda0351

Please sign in to comment.