mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Allow removing header in default header plugin (#3791)
Co-authored-by: Opender Singh <opender94@gmail.com> Co-authored-by: Dimitri Mitropoulos <dimitrimitropoulos@gmail.com> Co-authored-by: Bing <zhangb@mskcc.org> Co-authored-by: Opender Singh <opender.singh@konghq.com>
This commit is contained in:
parent
09e3e370a2
commit
fdf89c8cf1
@ -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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@ -12,7 +12,12 @@ module.exports = function(context) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value==="null") {
|
||||||
|
context.request.removeHeader(name);
|
||||||
|
console.log(`[header] Remove default header ${name}`)
|
||||||
|
} else {
|
||||||
context.request.setHeader(name, value);
|
context.request.setHeader(name, value);
|
||||||
console.log(`[header] Set default header ${name}: ${value}`);
|
console.log(`[header] Set default header ${name}: ${value}`);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user