Only add authorization header if token exists
This commit is contained in:
@@ -39,12 +39,15 @@ export class KubernetesBackendClient implements KubernetesApi {
|
||||
): Promise<any> {
|
||||
const url = `${await this.discoveryApi.getBaseUrl('kubernetes')}${path}`;
|
||||
const idToken = await this.identityApi.getIdToken();
|
||||
const headers = {
|
||||
'Content-Type': 'application/json',
|
||||
} as { [header: string]: string };
|
||||
if (idToken) {
|
||||
headers.authorization = `Bearer ${idToken}`;
|
||||
}
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
authorization: `Bearer ${idToken}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
headers,
|
||||
body: JSON.stringify(requestBody),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user