Fix Telegram avatar proxy headers
All checks were successful
Build and deploy Backend / build (push) Successful in 35s
All checks were successful
Build and deploy Backend / build (push) Successful in 35s
This commit is contained in:
@@ -105,7 +105,9 @@ export async function fetchTelegramPhoto(fileId: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
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()),
|
bytes: Buffer.from(await response.arrayBuffer()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ app.get('/telegram/photo/:fileId', async (request, reply) => {
|
|||||||
const photo = await fetchTelegramPhoto(params.fileId);
|
const photo = await fetchTelegramPhoto(params.fileId);
|
||||||
reply.header('content-type', photo.contentType);
|
reply.header('content-type', photo.contentType);
|
||||||
reply.header('cache-control', 'public, max-age=86400');
|
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);
|
return reply.send(photo.bytes);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user