This commit is contained in:
brow3c
2021-05-16 01:06:19 +09:00
parent 55cbefd7bb
commit 30b5203bcc
2 changed files with 5 additions and 3 deletions

View File

@@ -65,7 +65,9 @@ process.on('SIGTERM', exitHandler.bind(null, { cleanup: true }));
* request handler
*/
app.post('/', async (req, res, next) => {
browser.get(req.body).then(html => res.send(html)).catch(e => {
browser.get(req.body).then(result => {
typeof html == 'string' ? res.send(result) : res.json(result)
}).catch(e => {
logger.error({ message: e.message, info: e.info }, 'Browser error')
res.status(500).send({ code: 500, message: e.message })
})