Add extra time for jwt to expire
This commit is contained in:
@@ -118,7 +118,9 @@ export function AuthProvider({
|
||||
return config;
|
||||
}
|
||||
let currentJwt = jwt;
|
||||
if((expiration) && (expiration < new Date()) && (!config.url?.endsWith("/auth/refresh"))){
|
||||
const currentTime = new Date();
|
||||
currentTime.setSeconds(currentTime.getSeconds() + 5);
|
||||
if((expiration) && (expiration <= currentTime) && (!config.url?.endsWith("/auth/refresh"))){
|
||||
currentJwt = await fetchToken();
|
||||
config.headers.Authorization = jwt ? `Bearer ${currentJwt}` : config.headers.Authorization;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user