From ac1afc613fe77d3742baf9b6f7428707051c16ac Mon Sep 17 00:00:00 2001 From: blaisadmin Date: Sat, 2 May 2026 12:06:41 -0400 Subject: [PATCH] improved image handling --- backend/src/app.ts | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/backend/src/app.ts b/backend/src/app.ts index 3e74e13..7928140 100644 --- a/backend/src/app.ts +++ b/backend/src/app.ts @@ -2763,27 +2763,11 @@ app.get('/api/birds/:birdId/photo', async (req: Request, res: Response, next: Ne const signedUrl = getSignedS3ObjectUrl({ config: s3Config, objectKey: bird.photo_object_key, - expiresInSeconds: 60, + expiresInSeconds: 5 * 60, }); - const imageResponse = await fetch(signedUrl); - if (!imageResponse.ok) { - res.status(imageResponse.status).json({ error: 'Unable to load bird photo.' }); - return; - } - - const contentType = imageResponse.headers.get('content-type') || bird.photo_content_type || 'application/octet-stream'; - const contentLength = imageResponse.headers.get('content-length'); - const imageBuffer = Buffer.from(await imageResponse.arrayBuffer()); - - res.setHeader('Content-Type', contentType); res.setHeader('Cache-Control', 'private, max-age=300'); - - if (contentLength) { - res.setHeader('Content-Length', contentLength); - } - - res.send(imageBuffer); + res.redirect(302, signedUrl); } catch (error) { next(error); }