Skip to content

Commit

Permalink
fix(auth): prevent 'Bearer null' authorization header
Browse files Browse the repository at this point in the history
  • Loading branch information
undrcrxwn committed Nov 6, 2023
1 parent bc9dd74 commit e1a48cb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/shared/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ export interface ConnectTokenResponse {
}

localApi.interceptors.request.use((config) => {
config.headers.Authorization = `Bearer ${localStorage.getItem(LOCAL_STORAGE_ACCESS_TOKEN_KEY)}`;
const accessToken = localStorage.getItem(LOCAL_STORAGE_ACCESS_TOKEN_KEY);
if (accessToken) {
config.headers.Authorization = `Bearer ${accessToken}`;
}
return config;
});

Expand Down Expand Up @@ -55,11 +58,11 @@ export const signInFx = createEffect<SignIn, void>((form) => {
return requestFx({
method: 'POST',
path: '/connect/token',
body: {
body: new URLSearchParams({
grant_type: 'password',
scope: 'offline_access',
...form,
},
}),
});
});

Expand Down

0 comments on commit e1a48cb

Please sign in to comment.