diff options
author | Joanne <zehan_ding@brown.edu> | 2025-06-20 10:18:38 -0400 |
---|---|---|
committer | Joanne <zehan_ding@brown.edu> | 2025-06-20 10:18:38 -0400 |
commit | 61787b3c1cf53c0230f6142bee0df30c65971012 (patch) | |
tree | 36c43ca031722b9a92f3f344288c8f6cf7fff5e1 /src/server/server_Initialization.ts | |
parent | 2aa2c26b95a539d220e46b20cdfbef6ae39d6c43 (diff) | |
parent | e7a96fa043cfc9c3c426e09bbef42c8df88a45f6 (diff) |
Merge branch 'master' of https://github.com/brown-dash/Dash-Web into joanne-tutorialagent
Diffstat (limited to 'src/server/server_Initialization.ts')
-rw-r--r-- | src/server/server_Initialization.ts | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/server/server_Initialization.ts b/src/server/server_Initialization.ts index 80cf977ee..5deb66caf 100644 --- a/src/server/server_Initialization.ts +++ b/src/server/server_Initialization.ts @@ -126,10 +126,13 @@ function registerCorsProxy(server: express.Express) { //res.status(400).json({ error: 'Invalid URL format' }); return; } + + const isBinary = /\.(gif|png|jpe?g|bmp|webp|ico|pdf|zip|mp3|mp4|wav|ogg)$/i.test(targetUrl as string); + const responseType = isBinary ? 'arraybuffer' : 'text'; const response = await axios.get(targetUrl as string, { headers: { 'User-Agent': req.headers['user-agent'] || 'Mozilla/5.0' }, - responseType: 'text', + responseType: responseType }); const baseUrl = new URL(targetUrl as string); |