diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 9becf7d49f..628b85744c 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -146,7 +146,7 @@ export default { } }, mounted () { - this.$store.dispatch('account/checkState') + useAccountAuthStore().checkState() useProductBrokersStore().checkFlags() }, methods: { diff --git a/frontend/src/api/client.js b/frontend/src/api/client.js index 9ab80915d5..fa830aa88e 100644 --- a/frontend/src/api/client.js +++ b/frontend/src/api/client.js @@ -12,24 +12,21 @@ const client = axios.create({ // Common error handler client.interceptors.response.use(function (response) { return response -}, function (error) { +}, async function (error) { if (/^http/.test(error.config.url)) { // This request is to an external URL. Allow this error to pass back to the caller return Promise.reject(error) } - // This is an error response from our own API (or failure to reach it) - // Lazy require to avoid circular dependency: - // api/client.js → stores/account-auth.js → api/user.js → api/client.js - const { useAccountAuthStore } = require('../stores/account-auth.js') - const { useUxLoadingStore } = require('../stores/ux-loading.js') - const store = require('../store/index.js').default + // Dynamic import breaks the circular dep: client.js → account-auth.js → api/* → client.js + const { useAccountAuthStore } = await import('../stores/account-auth.js') + const { useUxLoadingStore } = await import('../stores/ux-loading.js') if (error.code === 'ERR_NETWORK') { // Backend failed to respond useUxLoadingStore().setOffline(true) } else if (error.response && error.response.status === 401 && !useUxLoadingStore().appLoader && !useAccountAuthStore().loginInflight) { // 401 when !pending && !loginInflight means the session has expired - store.dispatch('account/logout') + useAccountAuthStore().logout() } else if (error.response && error.response.status === 500) { // show toast notification Alerts.emit(error.response.data.error + ': ' + error.response.data.message, 'warning', 7500) diff --git a/frontend/src/components/Offline.vue b/frontend/src/components/Offline.vue index b49e40d05a..da8205e7fb 100644 --- a/frontend/src/components/Offline.vue +++ b/frontend/src/components/Offline.vue @@ -10,11 +10,13 @@