koajs 中的原始重定向不正确

Origin incorrect redirection in koajs

我在 my.origin1/myendpoint 有一个端点重定向到另一个端点:

router.get('/myendpoint', {
  var param = this.query.myParam;
  this.redirect(`http://my.origin2/myotherendpoint?param=${param}`);
  console.log(JSON.stringify(this.request.header,undefined,2));
})

控制台日志输出显示:

{
  "location": "http://my.origin2/myotherendpoint?param=myParamValue",
  "content-type": "text/html; charset=utf-8",
  "content-length": "whatever"
}

但是,重定向请求得到一个 404,当我在 fiddler 中观察它时,我看到位置 header 和 my.origin1/myotherendpoint?param=myParamValue。可能是什么原因造成的?

我已经浏览了代码,没有任何中间件拦截请求,我还检查了我们的 IIS 设置,没有 url 重定向可以影响这个。

找到解决方案。

IIS 需要将代理设置 reverseRewriteHostInResponseHeaders 设置为 false