this is the code for forwarding, but the front end of ctx.response.body is 404
.router.get("/getData", async (ctx, next) => {
let opts = Object.keys(ctx.query).reduce((pre, item, index) => {
return pre += `${item}=${encodeURIComponent(ctx.query[item])}&`
}, "?")
// const getData = await request.get(`https://searchapi.hc360.com/getmmtlast.cgi${opts}`)
// console.log("getData", getData.query);
request({
url: `https://searchapi.hc360.com/getmmtlast.cgi${opts}`,
method: "GET",
encoding: null
}, function(err, res, data) {
if (!err && res.statusCode == 200) {
console.log("data", Iconv.decode(data, "gbk"));
ctx.response.body = Iconv.decode(data, "gbk")
} else ctx.response.body = err;
})
await next();
})