Skip to content

Commit 7888c54

Browse files
committed
fix: handle Authorization header for different header types
1 parent b92939d commit 7888c54

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/tushan/client/api/auth/createAuthHTTPClient.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ export function createAuthHttpClient(
1313
const { token } = JSON.parse(
1414
window.localStorage.getItem(authStorageKey) ?? '{}'
1515
);
16-
(options.headers as Headers).set('Authorization', `Bearer ${token}`);
16+
17+
if (options.headers instanceof Headers) {
18+
options.headers.set('Authorization', `Bearer ${token}`);
19+
} else {
20+
(options.headers as Record<string, string>)[
21+
'Authorization'
22+
] = `Bearer ${token}`;
23+
}
1724

1825
return fetchJSON(url, options);
1926
} catch (err) {

0 commit comments

Comments
 (0)