Fix msg.responseUrl

The original version would pick up the proxy servers port number
This commit is contained in:
Ben Hardill 2021-05-12 11:08:57 +01:00
parent 4c8e895ac7
commit 8c1a749a5a
No known key found for this signature in database
GPG Key ID: 74DD076979ABB1E7
1 changed files with 2 additions and 8 deletions

View File

@ -364,7 +364,7 @@ module.exports = function(RED) {
proxyOptions.proxy.password = proxyPassword;
}
}
//need both incase of http -> https redirec
//need both incase of http -> https redirect
opts.agent = {
http: new HttpProxyAgent(proxyOptions),
https: new HttpsProxyAgent(proxyOptions)
@ -385,13 +385,7 @@ module.exports = function(RED) {
got(url,opts).then(res => {
msg.statusCode = res.statusCode;
msg.headers = res.headers;
let hostname = res.req.host;
if (res.req.protocol === "http:" && res.socket.remotePort !== 80) {
hostname = `${hostname}:${res.socket.remotePort}`
} else if (res.req.protocol === "https:" && res.socket.remotePort !== 443) {
hostname = `${hostname}:${res.socket.remotePort}`
}
msg.responseUrl = `${res.req.protocol}//${hostname}${res.req.path}`;
msg.responseUrl = res.url;
msg.payload = res.body;
msg.redirectList = redirectList;
msg.retry = 0;