diff --git a/CHANGELOG.md b/CHANGELOG.md index 47f965fbac0..baa9be6e25f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### vNEXT - Fix: Serialize arrays as JSON on fetch in `RESTDataSource`. [PR #2219](https://github.com/apollographql/apollo-server/pull/2219) +- Fix: The `privateHeaders` configuration for `apollo-engine-reporting` now allows headers to be specified using any case and lower-cases them prior to comparison. [PR #2276](https://github.com/apollographql/apollo-server/pull/2276) ### v2.3.3 diff --git a/packages/apollo-engine-reporting/src/extension.ts b/packages/apollo-engine-reporting/src/extension.ts index 86ad82476a5..bbc31a26860 100644 --- a/packages/apollo-engine-reporting/src/extension.ts +++ b/packages/apollo-engine-reporting/src/extension.ts @@ -125,11 +125,14 @@ export class EngineReportingExtension for (const [key, value] of o.request.headers) { if ( this.options.privateHeaders && - typeof this.options.privateHeaders === 'object' && + Array.isArray(this.options.privateHeaders) && // We assume that most users only have a few private headers, or will // just set privateHeaders to true; we can change this linear-time // operation if it causes real performance issues. - this.options.privateHeaders.includes(key.toLowerCase()) + this.options.privateHeaders.some(privateHeader => { + // Headers are case-insensitive, and should be compared as such. + return privateHeader.toLowerCase() === key.toLowerCase(); + }) ) { continue; } @@ -164,7 +167,7 @@ export class EngineReportingExtension Object.keys(o.variables).forEach(name => { if ( this.options.privateVariables && - typeof this.options.privateVariables === 'object' && + Array.isArray(this.options.privateVariables) && // We assume that most users will have only a few private variables, // or will just set privateVariables to true; we can change this // linear-time operation if it causes real performance issues.