From fa2980535f844ae3de39eb0a31f0bb79d90ffe0c Mon Sep 17 00:00:00 2001 From: Michael Bromley Date: Wed, 26 Aug 2020 11:09:38 +0200 Subject: [PATCH] fix(admin-ui): Fix channel header when using bearer auth --- .../src/lib/core/src/data/data.module.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/admin-ui/src/lib/core/src/data/data.module.ts b/packages/admin-ui/src/lib/core/src/data/data.module.ts index ecc5e114a6..a75c86d4c3 100644 --- a/packages/admin-ui/src/lib/core/src/data/data.module.ts +++ b/packages/admin-ui/src/lib/core/src/data/data.module.ts @@ -48,26 +48,18 @@ export function createApollo( new OmitTypenameLink(), new CheckJobsLink(injector), setContext(() => { + const headers: Record = {}; const channelToken = localStorageService.get('activeChannelToken'); if (channelToken) { - return { - headers: { - 'vendure-token': channelToken, - }, - }; + headers['vendure-token'] = channelToken; } - }), - setContext(() => { if (tokenMethod === 'bearer') { const authToken = localStorageService.get('authToken'); if (authToken) { - return { - headers: { - authorization: `Bearer ${authToken}`, - }, - }; + headers.authorization = `Bearer ${authToken}`; } } + return { headers }; }), createUploadLink({ uri: `${serverLocation}/${adminApiPath}`,