-
Notifications
You must be signed in to change notification settings - Fork 235
Description
Hello there,
Recently I've got some troubles using this module.
I'm trying something like that:
app.get('/users/a', proxy(serviceUrl, {
proxyReqPathResolver: function(req) {
return parseurl(req).path.replace('/a', '/b');
},
userResDecorator: function(proxyRes, proxyResData, userReq, userRes) {
const items = JSON.parse(proxyResData.toString('utf-8')).data;
...
return JSON.stringify(modifiedItems);
}
}));When I do the first request from my client, which has no custom headers set, I get a 200 HTTP response code, everything's as expected. But, when I do the same request again, e.g. refreshing the page, and I gettting a 304 status code, the variable proxyResData is an empty Buffer ( which shouldn't be happening in this case ), hence my app crashs due to the JSON parse error.
Weirdly it only happens when I get a 304 status code as response.
I could "solve" it using a workaround to avoid the 304 so far: setting the param cache-control to no- cache in the request headers on my client request, however I wouldn't like to do this.
I'm looking forward to hear from you if I'm doing something wrongly or if any of you experienced this same situation.
Thanks.