簡體   English   中英

節點JS HTTP代理-創建的URL問題

[英]Node JS http-proxy - issue with created URL

我在節點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對不起,如果問題的格式不正確或過於簡單-這是我第一次在堆棧上提問

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

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM