【问题标题】:Node JS http-proxy - issue with created URLNode JS http-proxy - 创建 URL 的问题
【发布时间】:2015-01-20 15:41:55
【问题描述】:

我在 node JS 中创建了简单的代理服务器,它看起来像这样:

var httpProxy = require('http-proxy');

var proxy = httpProxy.createProxyServer({});

//proxy config
app.all('/proxy/*', function (request, response) {
    "use strict";
    return proxy.web(request, response, {
    target: 'http://localhost:1234/'
    });
});

我遇到的问题是它从假设示例请求创建代理 URL:

$http.get('/proxy/example')
        .success( function(res) {
          $scope.quote = res;
          alert($scope.quote);
          })

看起来像这样:

localhost:1234/proxy/example

但我希望它创建如下所示的 URL:

localhost:1234/example

我做错了什么?

PS 抱歉,如果问题的格式不正确或太简单 - 这是我在堆栈上的第一个问题

【问题讨论】:

    标签: javascript node.js http-proxy


    【解决方案1】:

    不要做 /proxy/example 而是只写例子

       $http.get('example')
        .success( function(res) {
          $scope.quote = res;
          alert($scope.quote);
          })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-30
      • 2018-08-10
      • 1970-01-01
      • 2018-12-03
      • 1970-01-01
      • 2021-10-07
      • 2020-11-22
      • 1970-01-01
      相关资源
      最近更新 更多