diff --git a/web/app/components/share/utils.ts b/web/app/components/share/utils.ts index 0c6457fb0c..3f5303dfcc 100644 --- a/web/app/components/share/utils.ts +++ b/web/app/components/share/utils.ts @@ -32,6 +32,7 @@ export const checkOrSetAccessToken = async (appCode?: string | null) => { [userId || 'DEFAULT']: res.access_token, } localStorage.setItem('token', JSON.stringify(accessTokenJson)) + localStorage.removeItem(CONVERSATION_ID_INFO) } } diff --git a/web/service/base.ts b/web/service/base.ts index aa6c77716f..33aebf9cfb 100644 --- a/web/service/base.ts +++ b/web/service/base.ts @@ -398,9 +398,7 @@ export const ssePost = async ( .then((res) => { if (!/^[23]\d{2}$/.test(String(res.status))) { if (res.status === 401) { - refreshAccessTokenOrRelogin(TIME_OUT).then(() => { - ssePost(url, fetchOptions, otherOptions) - }).catch(() => { + if (isPublicAPI) { res.json().then((data: any) => { if (isPublicAPI) { if (data.code === 'web_app_access_denied') @@ -417,7 +415,14 @@ export const ssePost = async ( } } }) - }) + } + else { + refreshAccessTokenOrRelogin(TIME_OUT).then(() => { + ssePost(url, fetchOptions, otherOptions) + }).catch((err) => { + console.error(err) + }) + } } else { res.json().then((data) => {