HTTP Proxy using Connect and node-http-proxy

后端 未结 1 817
旧时难觅i
旧时难觅i 2021-01-07 15:49

I need a HTTP-Proxy to access an external API while I\'m developing to get around cross domain security restrictions.

I found some example code here: http://nthloop.

1条回答
  •  梦谈多话
    2021-01-07 16:13

    Local server is getting stuck because the middleware does not delegate handling of cases when the if condition fails further down the middleware chain :

    The following should solve the problem :

    
      .use(function(req, res, next) {
        if (req.url.indexOf(endpoint.prefix) === 0) {
          proxy.proxyRequest(req, res, endpoint);
        } else next();
      })
    

    0 讨论(0)
提交回复
热议问题