代码之家  ›  专栏  ›  技术社区  ›  Eamonn McEvoy

koajs中的源错误重定向

  •  0
  • Eamonn McEvoy  · 技术社区  · 7 年前

    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中观察到它时,我看到位置标头 my.origin1/myotherendpoint?param=myParamValue

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

    1 回复  |  直到 7 年前
        1
  •  0
  •   Eamonn McEvoy    7 年前

    找到了解决方案。

    reverseRewriteHostInResponseHeaders false