Skip to content

Commit 4de7d50

Browse files
committed
fix: drive-by middleware adjustment
1 parent e2e296b commit 4de7d50

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/common/atlas/apiClient.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ export class ApiClient {
5555
return this.accessToken?.token.access_token as string | undefined;
5656
};
5757

58-
private authMiddleware = (apiClient: ApiClient): Middleware => ({
59-
async onRequest({ request, schemaPath }) {
58+
private authMiddleware: Middleware = {
59+
onRequest: async ({ request, schemaPath }) => {
6060
if (schemaPath.startsWith("/api/private/unauth") || schemaPath.startsWith("/api/oauth")) {
6161
return undefined;
6262
}
6363

6464
try {
65-
const accessToken = await apiClient.getAccessToken();
65+
const accessToken = await this.getAccessToken();
6666
request.headers.set("Authorization", `Bearer ${accessToken}`);
6767
return request;
6868
} catch {
6969
// ignore not availble tokens, API will return 401
7070
}
7171
},
72-
});
72+
};
7373

7474
private readonly errorMiddleware: Middleware = {
7575
async onResponse({ response }) {
@@ -108,7 +108,7 @@ export class ApiClient {
108108
tokenPath: "/api/oauth/token",
109109
},
110110
});
111-
this.client.use(this.authMiddleware(this));
111+
this.client.use(this.authMiddleware);
112112
}
113113
this.client.use(this.errorMiddleware);
114114
}

0 commit comments

Comments
 (0)