Cuadrix / puppeteer-page-proxy

Additional module to use with 'puppeteer' for setting proxies per page basis.
428 stars 100 forks source link

json data need object not string #47

Closed xzh12 closed 2 years ago

xzh12 commented 4 years ago

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 });