Closed xzh12 closed 2 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 });
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 });