diff --git a/plugins/insomnia-plugin-default-headers/README.md b/plugins/insomnia-plugin-default-headers/README.md index b119de8c39..5a7d613f05 100644 --- a/plugins/insomnia-plugin-default-headers/README.md +++ b/plugins/insomnia-plugin-default-headers/README.md @@ -21,4 +21,11 @@ Headers can be added by setting a `DEFAULT_HEADERS` environment variable. } } ``` - +Default header can be removed by setting value to null. For example, use folder environment variables to remove authorization header from anonymous calls +```json +{ + "DEFAULT_HEADERS": { + "Authorization": "null" + } +} +``` diff --git a/plugins/insomnia-plugin-default-headers/src/default-headers.js b/plugins/insomnia-plugin-default-headers/src/default-headers.js index 98e9d24186..1f5b978c9c 100644 --- a/plugins/insomnia-plugin-default-headers/src/default-headers.js +++ b/plugins/insomnia-plugin-default-headers/src/default-headers.js @@ -12,7 +12,12 @@ module.exports = function(context) { continue; } - context.request.setHeader(name, value); - console.log(`[header] Set default header ${name}: ${value}`); + if (value==="null") { + context.request.removeHeader(name); + console.log(`[header] Remove default header ${name}`) + } else { + context.request.setHeader(name, value); + console.log(`[header] Set default header ${name}: ${value}`); + } } };