-
Notifications
You must be signed in to change notification settings - Fork 24
for multipart file or large body pay load 'useForward' is making request to fail when some async task needs to be done like fetching data from some api. #105
Comments
Can you show some code? |
proxy
.useForward(function(req, res, next) {
var cookies = cookie.parse(req.headers.cookie);
if (cookies.token) {
var session = JSON.parse(redis.getSession(cookies.token)); // this line is redis call which is async task and will take some time
if (session) {
req.headers['authorization'] = session.token.accessToken;
req.headers['auth-provider'] = session.token.authProvider;
}
next();
} else {
next();
}
}
}) |
What about something like, assuming it's a callback-based async code: proxy.useForward(function(req, res, next) {
var cookies = cookie.parse(req.headers.cookie);
if (cookies.token) {
redis.getSession(cookies.token, (err, token) => {
if (err) {
// do something with the error
return next(err)
}
var session = JSON.parse(token)
if (session) {
req.headers['authorization'] = session.token.accessToken;
req.headers['auth-provider'] = session.token.authProvider;
}
next()
})
} else {
next();
}
}
}) |
yeh tried, that is not working :( |
in Nginx it is giving me : prematurely closed connection while reading response header from upstream client My nginx config server_name peoplehum.dev www.peoplehum.dev; #include /etc/nginx/proxy_header.conf; #X-Forwarded-Proto header gives the proxied server information about the schema of the original client request (whether it was an http or an https request). #The X-Real-IP is set to the IP address of the client so that the proxy can correctly make decisions or log based on this information. #The X-Forwarded-For header is a list containing the IP addresses of every server the client has been proxied through up to this point. |
Please help me with this. As for every request, I have to query Redis to get data and attach them in header and pass it to respective java APIs. It is making request fail when there is file need to be send.
The text was updated successfully, but these errors were encountered: