Heroku Node.js node-http-proxy模块没有这样的应用程序错误

我试图将stream量从我的testing应用程序的/ api / * urlredirect到Heroku托pipe的我的api。

因此,应将localhost / api / hello代理到testapp.heroku.com/hello,并返回响应。

使用node-http-proxy在localhost到localhost上完美工作,但是当我将它指向myapp.heroku.com时,我得到这个错误:

Heroku | No such app There is no app configured at that hostname. Perhaps the app owner has renamed it, or you mistyped the URL. 

我感觉Heroku的路由系统正在欺骗我的代理请求,而且我还没有find解决这个问题的方法。 有任何想法吗?

当接近不同域的请求时,我看到了类似的东西。 我使用的工作是修改代理请求上的主机头以匹配远程站点所期望的域名。 所以在你的情况下,代码将如下所示:

 var http = require('http'), httpProxy = require('http-proxy'); var server = httpProxy.createServer(function (req, res, proxy) { req.headers.host = 'myapp.heroku.com'; proxy.proxyRequest(req, res, { port: 80, host: 'myapp.heroku.com' }); }).listen(9000); 

我有兴趣知道这是否适合你。