Skip to content

Commit 1af72ce

Browse files
fix: 401 responses =>retry only once (#258)
1 parent 77c090d commit 1af72ce

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

client/src/app/axios-config/apiInit.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,24 @@ export const initInterceptors = () => {
4848
try {
4949
const refreshedUser = await userManager.signinSilent();
5050
const access_token = refreshedUser?.access_token;
51+
52+
const retryCounter = error.config.retryCounter || 1;
53+
5154
const retryConfig = {
5255
...error.config,
5356
headers: {
5457
...error.config.headers,
5558
Authorization: `Bearer ${access_token}`,
5659
},
5760
};
58-
return axios(retryConfig);
61+
62+
// Retry limited times
63+
if (retryCounter < 2) {
64+
return axios({
65+
...retryConfig,
66+
retryCounter: retryCounter + 1,
67+
});
68+
}
5969
} catch (refreshError) {
6070
await userManager.signoutRedirect();
6171
}

0 commit comments

Comments
 (0)