No response using express proxy route

后端 未结 5 903
执念已碎
执念已碎 2020-12-07 08:55

I\'ve written a small proxy with nodejs, express and htt-proxy. It works well for serving local files but fails when it comes to proxy to external api:

var e         


        
5条回答
  •  情歌与酒
    2020-12-07 09:33

    Maybe your code is different when you're testing, but I'm querying the same URL as in your code sample using the following:

    http://query.yahooapis.com:8080/v1/public/yql?q=show%20tables&format=json&callback=

    and I get nothing back. My guess is you want to change port to 80 (from 8080) -- it works when I change it like so:

    http://query.yahooapis.com:80/v1/public/yql?q=show%20tables&format=json&callback=

    So that means it should be:

    proxy.proxyRequest(req, res, {
        host: 'query.yahooapis.com', //yahoo is just an example to verify its not the apis fault
        port: 80
    });
    

提交回复
热议问题