Fix Telegram avatar proxy headers
All checks were successful
Build and deploy Backend / build (push) Successful in 35s

This commit is contained in:
Ruslan Bakiev
2026-05-08 20:01:32 +07:00
parent 387a504801
commit 6471d2ffcf
2 changed files with 5 additions and 1 deletions

View File

@@ -105,7 +105,9 @@ export async function fetchTelegramPhoto(fileId: string) {
}
return {
contentType: response.headers.get('content-type') ?? 'image/jpeg',
contentType: file.file_path.toLowerCase().endsWith('.png')
? 'image/png'
: 'image/jpeg',
bytes: Buffer.from(await response.arrayBuffer()),
};
}

View File

@@ -41,6 +41,8 @@ app.get('/telegram/photo/:fileId', async (request, reply) => {
const photo = await fetchTelegramPhoto(params.fileId);
reply.header('content-type', photo.contentType);
reply.header('cache-control', 'public, max-age=86400');
reply.header('access-control-allow-origin', '*');
reply.header('cross-origin-resource-policy', 'cross-origin');
return reply.send(photo.bytes);
});