Skip to content

Commit 767c4f6

Browse files
committed
fix; return image header
1 parent 382120f commit 767c4f6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

app.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,19 @@ app.get('/history/charts/:country', async (req, res, next) => {
226226
const browser = await puppeteer.launch({
227227
args: chrome.args,
228228
executablePath: await chrome.executablePath,
229-
headless: false,
229+
headless: chrome.headless,
230230
defaultViewport: {width: 1440, height: 800},
231231
});
232232

233233
const page = await browser.newPage();
234234
//page.setViewport({width: 1440, height: 800})
235235
await page.goto(req.protocol + '://' + req.get('host') +'/history/charts/web/'+s.country);
236-
let p = await page.screenshot({encoding: 'base64', type: 'png'});
237-
//await browser.close();
238-
return res.send(`<html><body style="margin:0;padding:0;"><img src="data:image/png;base64, ${p}" width="100%"/></body></html>`)
236+
let p = await page.screenshot({type: 'png'});
237+
await browser.close();
238+
res.statusCode = 200;
239+
res.setHeader('Content-Type', `image/png`);
240+
res.end(p);
241+
//return res.send(`<html><body style="margin:0;padding:0;"><img src="data:image/png;base64, ${p}" width="100%"/></body></html>`)
239242
})
240243

241244
app.get('*', (req, res) => res.send(`

0 commit comments

Comments
 (0)