directus/directus

Support proxies for file storage adapters

Open

#24 381 ouverte le 10 janv. 2025

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)TypeScript (25 193 stars) (3 505 forks)batch import
EngineHelp WantedImprovement

Description

Describe the Bug

While trying to upload a file to s3 on a machine where there is an environment variable for proxy, this is ignored by the httpAgent and httpsAgent, so the upload is always blocked, to solve this we swapped both agent for ProxyAgent, everything works the same but proxy variables are retrived and used correctly

+import { ProxyAgent } from "proxy-agent";
 var DriverS3 = class {
   config;
   client;
@@ -54,8 +53,8 @@ var DriverS3 = class {
       requestHandler: new NodeHttpHandler({
         connectionTimeout,
         socketTimeout,
-        httpAgent: new HttpAgent({ maxSockets, keepAlive }),
-        httpsAgent: new HttpsAgent({ maxSockets, keepAlive })
+        httpAgent: new ProxyAgent({ maxSockets, keepAlive }),
+        httpsAgent: new ProxyAgent({ maxSockets, keepAlive })
       })

To Reproduce

Try to upload a file to s3 through a machine that needs a proxy to make requests to external services

Directus Version

11.3.5

Hosting Strategy

Self-Hosted (Docker Image)

Database

No response

Guide contributeur