1
0
mirror of https://github.com/dap-ps/discover.git synced 2025-02-07 06:54:49 +00:00

fix setting of Cache-Control for dapp images

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-11-06 18:58:24 +01:00
parent e2dcd26e51
commit bf8b9bcbad
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020

View File

@ -103,17 +103,18 @@ class DAppsMetadataController {
try {
const dappImage = await DAppImageService.retrieveImage(req.params.hash)
if (dappImage) {
const imageBuffer = Buffer.from(dappImage.content, 'base64')
res.writeHead(200, {
'Content-Type': 'image/png',
'Content-Length': imageBuffer.length,
})
return void res.end(imageBuffer)
if (!dappImage) {
res.status(404).send()
}
res.status(404).send()
const imageBuffer = Buffer.from(dappImage.content, 'base64')
/* allow for caching of images, since they are the bulk of requests */
res.set('Cache-Control', 'public, max-age=31557600')
res.set('Content-Type', 'image/png')
res.set('Content-Length', imageBuffer.length)
res.status(200)
return void res.end(imageBuffer)
} catch (error) {
logger.error(error.message)
res.status(404).send()