From d8caa16efecbaef0645d4550a568d28f298ca4bb Mon Sep 17 00:00:00 2001 From: Yaacov Zamir Date: Tue, 30 Aug 2022 16:05:21 +0300 Subject: [PATCH] Use the K8S_AUTH_BEARER_TOKEN env var for authorizedFetch (#986) Signed-off-by: yzamir Signed-off-by: yzamir --- pkg/web/src/app/queries/fetchHelpers.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/web/src/app/queries/fetchHelpers.ts b/pkg/web/src/app/queries/fetchHelpers.ts index 4a5d596c..a1d973f6 100644 --- a/pkg/web/src/app/queries/fetchHelpers.ts +++ b/pkg/web/src/app/queries/fetchHelpers.ts @@ -33,6 +33,10 @@ export const authorizedFetch = async ( extraHeaders['Authorization'] = `Bearer ${fetchContext.currentUser.access_token}`; } + if (ENV.AUTH_REQUIRED === 'false' && ENV.K8S_AUTH_BEARER_TOKEN) { + extraHeaders['Authorization'] = `Bearer ${ENV.K8S_AUTH_BEARER_TOKEN}`; + } + try { const response = await fetch(url, { headers: extraHeaders,