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:
ThisNoName 2021-08-25 03:08:29 -04:00 committed by GitHub
parent 09e3e370a2
commit fdf89c8cf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -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"
}
}
```

View File

@ -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}`);
}
}
};