Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions packages/cli-kit/src/public/node/graphiql/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,8 @@ const BLOCKED_HEADERS = new Set([
* @returns The subset of headers that are safe to forward to the Admin API.
*/
export function filterCustomHeaders(headers: {[key: string]: string | string[] | undefined}): {[key: string]: string} {
const customHeaders: {[key: string]: string} = {}
for (const [key, value] of Object.entries(headers)) {
if (!BLOCKED_HEADERS.has(key.toLowerCase()) && typeof value === 'string') {
customHeaders[key] = value
}
}
return customHeaders
const validEntries = Object.entries(headers).filter(
(entry): entry is [string, string] => !BLOCKED_HEADERS.has(entry[0].toLowerCase()) && typeof entry[1] === 'string',
)
return Object.fromEntries(validEntries)
}
Loading