Skip to content

Commit

Permalink
fix(cacheClient): set auth header
Browse files Browse the repository at this point in the history
  • Loading branch information
JGiter committed Nov 22, 2021
1 parent 66b82d9 commit ba9e870
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/modules/cacheClient/cacheClient.service.ts
Expand Up @@ -40,7 +40,7 @@ export class CacheClient implements ICacheClient {
this.authEnabled = cacheServerSupportsAuth;
this.isBrowser = executionEnvironment() === ExecutionEnvironment.BROWSER;
if (!this.isBrowser) {
this.httpClient.defaults.headers.common["Authorization"] = `Bearer ${this.token}`;
this.httpClient.defaults.headers.common["Authorization"] = this.authHeader;
}
}

Expand All @@ -57,6 +57,7 @@ export class CacheClient implements ICacheClient {
const { refreshToken, token } = await this.refreshToken();
if (await this.isAuthenticated()) {
this.refresh_token = refreshToken;

this.token = token;
return;
}
Expand Down Expand Up @@ -311,4 +312,8 @@ export class CacheClient implements ICacheClient {
return false;
}
}

private get authHeader() {
return `Bearer ${this.token}`;
}
}

0 comments on commit ba9e870

Please sign in to comment.