default to strict mode but permit settings

This commit is contained in:
Steve-Mcl 2024-03-17 16:34:42 +00:00
parent 5e3cbadffc
commit bf065ee11d
2 changed files with 15 additions and 9 deletions

View File

@ -57,11 +57,11 @@ const DEFAULT_PORTS = {
/**
* @typedef {Object} ProxyOptions
* @property {string} mode - Legacy mode is for non-strict previous proxy determination logic (node-red < v3.1) (default 'legacy')
* @property {boolean} favourUpperCase - Favour UPPER_CASE *_PROXY env vars (default false)
* @property {boolean} lowerCaseOnly - Prevent UPPER_CASE *_PROXY env vars being used. (default false)
* @property {boolean} excludeNpm - Prevent npm_config_*_proxy env vars being used. (default false)
* @property {object} env - The environment object to use (default process.env)
* @property {'strict'|'legacy'} [mode] - Legacy mode is for non-strict previous proxy determination logic (for node-red <= v3.1 compatibility) (default 'strict')
* @property {boolean} [favourUpperCase] - Favour UPPER_CASE *_PROXY env vars (default false)
* @property {boolean} [lowerCaseOnly] - Prevent UPPER_CASE *_PROXY env vars being used. (default false)
* @property {boolean} [excludeNpm] - Prevent npm_config_*_proxy env vars being used. (default false)
* @property {object} [env] - The environment object to use (defaults to process.env)
*/
/**
@ -74,16 +74,14 @@ const DEFAULT_PORTS = {
function getProxyForUrl(url, options) {
url = url || ''
const defaultOptions = {
mode: 'legacy', // TODO: change to 'strict' in V4.x
mode: 'strict',
lowerCaseOnly: false,
favourUpperCase: false,
excludeNpm: false,
}
options = Object.assign({}, defaultOptions, options)
//TODO: V4.x default: if mode is not set, default to strict mode
// if (options.mode === 'legacy') {
if (options.mode !== 'strict') {
if (options.mode === 'legacy') {
return legacyGetProxyForUrl(url, options.env || process.env)
}

View File

@ -244,6 +244,14 @@ module.exports = {
*/
//httpStaticRoot: '/static/',
/** The following property can be used to modify proxy options */
// proxyOptions: {
// mode: "legacy", // legacy mode is for non-strict previous proxy determination logic (node-red < v4 compatible)
// favourUpperCase: false, // Favour UPPER_CASE *_PROXY env vars
// lowerCaseOnly: false, // Prevent UPPER_CASE *_PROXY env vars being used.
// excludeNpm: false, // Prevent npm configured proxy env vars being used.
// },
/*******************************************************************************
* Runtime Settings
* - lang