Skip to content

Commit d3a694c

Browse files
committed
fix: always send 200 status when image is found
1 parent 69d62e8 commit d3a694c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/pages/api/images.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const images = async (req: NextApiRequest, res: NextApiResponse) => {
3333
// Get the image from the cache if it exists
3434
const image = imageCache.get(req.query.login as string);
3535
if (image) {
36-
res.send(image as Buffer);
36+
res.status(200).send(image as Buffer);
3737
} else {
3838
// Fetch the image from the user-photos server if it's not in the cache
3939
const response = await fetch(`${userPhotosServer}/${req.query.login}/100`);
@@ -42,7 +42,7 @@ const images = async (req: NextApiRequest, res: NextApiResponse) => {
4242
if (response.ok) {
4343
console.log(`Cache miss for ${req.query.login}, fetching image from user-photos.codam.nl...`);
4444
imageCache.set(req.query.login as string, buffer, 3600); // Cache the image for 1 hour
45-
res.status(response.status).send(buffer);
45+
res.status(200).send(buffer);
4646
} else {
4747
console.log(`Failed to fetch image for ${req.query.login} from user-photos.codam.nl`);
4848
res.status(response.status).send(buffer);

0 commit comments

Comments
 (0)