💊 fix: OpenID proxy support for downloading profile pictures (#3263)

Related to #3261

Add proxy support to `downloadImage` function in `openidStrategy.js`

* Import `HttpsProxyAgent` from `https-proxy-agent`.
* Add `agent` property to the fetch options in `downloadImage` function if `process.env.PROXY` is set.
* Update the `fetch` call in `downloadImage` function to use the proxy agent if available.
This commit is contained in:
Marco Beretta 2024-07-05 17:23:06 +03:00 committed by GitHub
parent 1edbfdbce2
commit e76777d298
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -25,12 +25,18 @@ const downloadImage = async (url, accessToken) => {
}
try {
const response = await fetch(url, {
const options = {
method: 'GET',
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
};
if (process.env.PROXY) {
options.agent = new HttpsProxyAgent(process.env.PROXY);
}
const response = await fetch(url, options);
if (response.ok) {
const buffer = await response.buffer();