Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lambda: Support case-insensitive headers in pre-request CORS logic.
I hope this will be an alternative implementation for the contribution made in #2597 by @dsanders11. While that solution will certainly works, it expands on our existing double-checking of multiple header CaSe-patterns in multiple locations, prior to GraphQL execution beginning. As a proposed alternative, rather than checking for two types of expected header capitalization combinations in every one of our checks (which I should note leaves out MaNy-OtHeR-Header-patterns which are perfectly valid since HTTP headers are, by specification, case-insensitive (see ref below), this uses the `Headers` implementation which we use within `apollo-server-core` to manage and manipulate headers. The `node-fetch` headers implementation takes care to store the headers in a case-insensitive manner internally: https://github.com/bitinn/node-fetch/blob/bf8b4e8db350ec76dbb9236620f774fcc21b8c12/src/headers.js#L267-L270 ...which should hopefully simplify the logic and make things behave more reliably if someone chooses to use a peculiar case for the header. As to Amazon's own difference in headers, it appears to be that it's a difference between their Application-Load Balancer behavior and the way that their AWS API Gateway functionality sends their `events` — the former being the case of the original request and the latter being lower-cased behind-the-scenes. Ref: https://tools.ietf.org/html/rfc7230#section-3.2 (RFC)
- Loading branch information