Skip to content

Commit

Permalink
Use an aHTTPS Agent and HTTPS scheme if RED.settings.https is set to …
Browse files Browse the repository at this point in the history
…something

closes #1480
  • Loading branch information
Steve-Mcl committed Nov 20, 2024
1 parent 105b2c4 commit 33bdf20
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion nodes/config/ui_base.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const { Agent } = require('https')
const path = require('path')

const axios = require('axios')
Expand Down Expand Up @@ -1130,7 +1131,17 @@ module.exports = function (RED) {
const host = RED.settings.uiHost
const port = RED.settings.uiPort
const httpAdminRoot = RED.settings.httpAdminRoot
const url = 'http://' + (`${host}:${port}/${httpAdminRoot}flows`).replace('//', '/')
let scheme = 'http://'
let httpsAgent
if (RED.settings.https) {
const https = (typeof RED.settings.https === 'function' ? RED.settings.https() : RED.settings.https) || {}
httpsAgent = new Agent({
rejectUnauthorized: false,
...https
})
scheme = 'https://'
}
const url = scheme + (`${host}:${port}/${httpAdminRoot}flows`).replace('//', '/')
console.log('url', url)
// get request body
const dashboardId = req.params.dashboardId
Expand Down Expand Up @@ -1234,6 +1245,7 @@ module.exports = function (RED) {
const getResponse = await axios.request({
method: 'GET',
headers: getHeaders,
httpsAgent,
url
})

Expand Down Expand Up @@ -1314,6 +1326,7 @@ module.exports = function (RED) {
const postResponse = await axios.request({
method: 'POST',
headers: postHeaders,
httpsAgent,
url,
data: {
flows,
Expand Down

0 comments on commit 33bdf20

Please sign in to comment.