Who can tell me why the, koa request server forwards why the front-end access is a 404?

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();
})
Jan.18,2022

if you want to learn to forward an interface, you can check
if it is to solve the problem of interface cross-domain or cross-service request interface, you can use koa-server-http-proxy

const proxy = require('koa-server-http-proxy');
app.use(proxy('/api', {
  target: 'https://www.shoujinwang.com/',
  pathRewrite: { '^/api': '/' },
  changeOrigin: true
}))

can be forwarded directly to interfaces with custom prefixes


because request is an asynchronous process, ctx.response.body is not executed when requesting / getData , where the result of await request is assigned to ctx

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31677-2bd94.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31677-2bd94.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?