/node_modules/http-proxy/lib/http-proxy/index.js:120; Error: socket hang up
Previous Post: /node_modules/http-proxy/lib/http-proxy/index.js:120; Error: socket hang up
I'm trying to use createProxyMiddleware({ target: serviceProvider})
instead of
apiProxy.web(req, res, {target: serviceProvider});
. The browser hangs and doesn't show anything (I see the spin in the tab though)
How do I properly use createProxyMiddleware with the nested codebase like below?
Here is the source code.
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);
}
}
},
);
Between, this works: app.get('/source*', createProxyMiddleware({ target: serviceProvider}))