From 919aee64f9fcc622988e6db8f652146dfca8a7e3 Mon Sep 17 00:00:00 2001 From: Ben Hardill Date: Fri, 11 Jun 2021 14:48:41 +0100 Subject: [PATCH] Add support for user/pass in URL --- .../@node-red/nodes/core/network/21-httprequest.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js index 42e403540..a498d4ac7 100644 --- a/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js +++ b/packages/node_modules/@node-red/nodes/core/network/21-httprequest.js @@ -207,17 +207,22 @@ module.exports = function(RED) { } if (this.credentials) { if (this.authType === "basic") { + // Workaround for https://github.com/sindresorhus/got/issues/1169 var cred = "" + var parsedURL = new URL(url) if (this.credentials.user) { // opts.username = this.credentials.user; cred = this.credentials.user + } else if (parsedURL.username) { + cred = parsedURL.username } if (this.credentials.password) { // opts.password = this.credentials.password; cred += ":" + this.credentials.password + } else if (parsedURL.password) { + cred += ":" + parsedURL.password } // build own basic auth header - // Workaround for https://github.com/sindresorhus/got/issues/1169 opts.headers.Authorization = "Basic " + Buffer.from(cred).toString("base64"); } else if (this.authType === "digest") { let digestCreds = this.credentials;