Skip to content

Commit 32eca80

Browse files
authored
fix: clear error overlay on successful comlink token creation (#572)
1 parent 4c6afb2 commit 32eca80

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/react/src/context/ComlinkTokenRefresh.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,21 @@ function DashboardTokenRefresh({children}: PropsWithChildren) {
6666

6767
if (res.token) {
6868
setAuthToken(instance, res.token)
69+
70+
// Remove the unauthorized error from the error container
71+
const errorContainer = document.getElementById('__sanityError')
72+
if (errorContainer) {
73+
const hasUnauthorizedError = Array.from(errorContainer.getElementsByTagName('div')).some(
74+
(div) =>
75+
div.textContent?.includes(
76+
'Uncaught error: Unauthorized - A valid session is required for this endpoint',
77+
),
78+
)
79+
80+
if (hasUnauthorizedError) {
81+
errorContainer.remove()
82+
}
83+
}
6984
}
7085
isTokenRefreshInProgress.current = false
7186
} catch {

0 commit comments

Comments
 (0)