【问题标题】:http-proxy-middleware: unable to redirect localhost:9000 to localhost:8888 from nodejs to JettYhttp-proxy-middleware:无法将 localhost:9000 重定向到 localhost:8888 从 nodejs 到 JettY
【发布时间】:2017-03-18 15:20:54
【问题描述】:

我有一个托管在 localhost:9000 的 Node.js(AngularJS 应用程序)应用程序。另一部分(旧版 - GWT superdev 模式 - JeTTy)托管在 localhost:8888。

我想配置 http-proxy-middleware 以便 localhost:9000 (NodeJS) 中的任何内容都应重定向到 localhost:8888 (JetTTy),并具有以下规范:(应用程序有 3 个端点):

https://localhost:9000/product -> http://127.0.0.1:8888/product https://localhost:9000/servlets/my_servlet1 -> http://127.0.0.1:8888/servlets/my_servlet1 https://localhost:9000/admin -> http://127.0.0.1:8888/admin

http-proxy-middleware 设置如下:

var proxy = proxyMiddleware(['/product', '/admin', '/servlets'], { 目标:'http://127.0.0.1:8888', 更改来源:真实, xfwd: 真的 }); var 应用程序 = 连接(); app.use(代理);

代理启动如下:

## 节点脚本/serve.js [HPM] 代理已创建:[ '/product, '/admin', '/servlets' ] -> http://127.0.0.1:8888 监听 9000 端口 https://localhost:9000

现在我正在尝试访问(通过 localhost:9000)端点,但失败了 http:500 错误:

请求网址:https://localhost:9000/servlets/my_servlet1 请求方法:POST 状态码:500 协议 = https 主机 = null 远程地址:[::1]:9000 HTTP 错误 500 访问 /servlets/my_servlet1 时出现问题。原因: 协议 = https 主机 = null 由码头提供支持://

我在这里缺少什么?

【问题讨论】:

  • 应该是https://localhost:9000还是http://localhost:9000

标签: angularjs node.js jetty gwt-super-dev-mode http-proxy-middleware


【解决方案1】:

您可以尝试使用http://localhost:9000 代替https://localhost:9000。您使用 https 的任何具体原因?

【讨论】:

    猜你喜欢
    • 2020-12-28
    • 2018-01-21
    • 2022-10-20
    • 1970-01-01
    • 2021-01-01
    • 2015-01-11
    • 1970-01-01
    • 1970-01-01
    • 2017-12-24
    相关资源
    最近更新 更多