/node_modules/http-proxy/lib/http-proxy/index.js:120; 错误:套接字挂起
上一篇:/node_modules/http-proxy/lib/http-proxy/index.js:120; 错误:套接字挂起
我正在尝试使用createProxyMiddleware({ target: serviceProvider})
而不是
apiProxy.web(req, res, {target: serviceProvider});
. 浏览器挂起并且不显示任何内容(尽管我在选项卡中看到了旋转)
如何正确使用带有嵌套代码库的 createProxyMiddleware,如下所示?
这是源代码。
app.get('/source*',
function(req, res, next) {
req.query.RelayState = req.url;
if(req.user) { // if user is authenticated,
if(req.originalUrl) {
resource_path = req.originalUrl.split('/source')[1];
console.log(req.user['email'] + ' is viewing ' + req.originalUrl);
}
createProxyMiddleware({ target: serviceProvider})
// apiProxy.web(req, res, {target: serviceProvider});
} else {
if(process.env.MODE=='HACK') {
createProxyMiddleware({ target: serviceProvider})
// apiProxy.web(req, res, {target: serviceProvider});
} else {
passport.authenticate('samlStrategy')(req, res, next);
}
}
},
);
之间,这有效:app.get('/source*', createProxyMiddleware({ target: serviceProvider}))