Skip to content

Commit cab9fe3

Browse files
committed
Add skipInitialFetch Option
1 parent 91d8589 commit cab9fe3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/client.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,14 @@ export interface IAuthOptions {
191191
* Default false
192192
*/
193193
disableRefreshOnFocus?: boolean
194+
195+
/**
196+
* If true, disables the token refresh on initial page load.
197+
* Can help reduce duplicate token refresh requests.
198+
*
199+
* Default false
200+
*/
201+
skipInitialFetch?: boolean
194202
}
195203

196204
interface AccessTokenActiveOrgMap {
@@ -666,7 +674,9 @@ export function createClient(authOptions: IAuthOptions): IAuthClient {
666674
}
667675

668676
if (authOptions.enableBackgroundTokenRefresh) {
669-
client.getAuthenticationInfoOrNull()
677+
if (!authOptions.skipInitialFetch) {
678+
client.getAuthenticationInfoOrNull()
679+
}
670680
clientState.refreshInterval = window.setInterval(client.getAuthenticationInfoOrNull, 60000)
671681
}
672682
}

0 commit comments

Comments
 (0)