Cuadrix / puppeteer-page-proxy

Additional module to use with 'puppeteer' for setting proxies per page basis.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

json data need object not string

xzh12 opened this issue · comments

commented

var validator = require('validator');

// console.log(request.url());
const respType = response.headers['content-type'].trim();
// console.log(respType);
if (respType === 'text/html;charset=UTF-8') {
const responseStr = Buffer.from(response.body).toString('utf-8');
if (validator.isJSON(responseStr)) {
response.contentType = 'application/json;charset=UTF-8';
response.headers['content-type'] = 'application/json;charset=UTF-8';
}
}
await request.respond({
status: response.statusCode,
headers: response.headers,
body: response.body
});