I have a node app using koa, and trying to retrieve remote pdf, and return it as a response of my koa request. Here is the code:
router.get('/pdf', function *() {
const url = 'http://example.com/pdf'
const res = yield request(url)
this.status = res.statusCode
Object.keys(res.headers).forEach(key => {
this.set(key, res.headers[key])
})
this.body = res.body
})
I get the pdf with blank page, but it should have content in it. Does anyone have an idea what could be the solution?