2014-09-29 2 views
2

nodeJs에서 프록시를 통해 연결을 시도하고 있지만 결과 나 오류가 없습니다. mikeal/request을 사용하고 있습니다.NodeJS의 프록시와 함께 "잘못된 프로토콜"을 받았습니다

나는 명령 줄에서 프록시를 테스트했는데 제대로 작동합니다

$ http_proxy=localhost:9060 wget http://wtfismyip.com/json 
$ cat json 

반환 예상대로

{ 
    "YourFuckingIPAddress" : "62.236.108.73", 
    "YourFuckingLocation" : "Finland", 
    "YourFuckingHostname" : "effi.org", 
    "YourFuckingISP" : "TDC Oy Finland" 
} 

. 그러나 nodeJs 내 요청 :

router.route('/proxy-ip') 
    .get(function (req, res) { 

     var request_options = { 
      url: 'http://wtfismyip.com/json', 
      proxy: { 
       host: "http://localhost", 
       port: 9060 
      } 
     }; 

     console.log({request:request_options}); 

     request.get(request_options, 
      function (error, response, json) { 
       if (!error && response.statusCode == 200) { 
        res.send(json); 
       } else { 
        console.log({'request': request, 'response': response, 'error': error, 'json': json}); 
        res.send({'response': response, 'error': error, 'json': json}); 
       } 
      } 
     ); 

    }); 

로그 잘못된 프로토콜 오류 :

error: [Error: Invalid protocol: http] 

사람이 그것을 해결하는 방법을 알고 있나요? 누구든지 mikeal에서 프록시를 사용하여 작업하고 있습니까/& nodejs를 요청 하시겠습니까?

답변

2

수정 됨! 문자열 &와

내가 대체 한 프록시 객체가 작동합니다

  proxy: 'http://localhost:9060', 
관련 문제