support env var NR_PROXY_MODE "legacy"|"strict"

pull/4616/head
Steve-Mcl 2024-03-17 17:21:33 +00:00
parent 1cf7b95891
commit 283f7f5992
1 changed files with 6 additions and 0 deletions

View File

@ -55,6 +55,8 @@ const DEFAULT_PORTS = {
mqtts: 8883
}
const modeOverride = getEnv('NR_PROXY_MODE', {})
/**
* @typedef {Object} ProxyOptions
* @property {'strict'|'legacy'} [mode] - Legacy mode is for non-strict previous proxy determination logic (for node-red <= v3.1 compatibility) (default 'strict')
@ -81,6 +83,10 @@ function getProxyForUrl(url, options) {
}
options = Object.assign({}, defaultOptions, options)
if (modeOverride === 'legacy' || modeOverride === 'strict') {
options.mode = modeOverride
}
if (options.mode === 'legacy') {
return legacyGetProxyForUrl(url, options.env || process.env)
}