Skip to content

Commit

Permalink
Merge pull request #380 from kunickiaj/ajk--fix-headers
Browse files Browse the repository at this point in the history
Use correct request type for extracting auth token
  • Loading branch information
taras authored Jan 23, 2024
2 parents ae97740 + e3d21a3 commit 26be7e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-horses-end.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@frontside/backstage-plugin-graphql-backend-module-catalog': patch
---

Corrects the request type used for extracting auth token for catalog requests.
4 changes: 2 additions & 2 deletions plugins/graphql-backend-module-catalog/src/entitiesLoadFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Entity } from '@backstage/catalog-model';
import { getBearerTokenFromAuthorizationHeader } from '@backstage/plugin-auth-node';
import { GraphQLContext, NodeQuery } from '@frontside/hydraphql';
import { GraphQLError } from 'graphql';
import type { Request } from 'express';
import type { Request } from 'node-fetch';
import { CATALOG_SOURCE } from './constants';

export const createCatalogLoader = (catalog: CatalogApi) => ({
Expand All @@ -13,7 +13,7 @@ export const createCatalogLoader = (catalog: CatalogApi) => ({
): Promise<Array<Entity | GraphQLError>> => {
// TODO: Support fields
const request = context.request;
const token = request ? getBearerTokenFromAuthorizationHeader(request.headers.authorization) : undefined;
const token = getBearerTokenFromAuthorizationHeader(request?.headers.get('authorization'));
const entityRefs = queries.reduce(
(refs, { ref } = {}, index) => (ref ? refs.set(index, ref) : refs),
new Map<number, string>(),
Expand Down

0 comments on commit 26be7e2

Please sign in to comment.