From 423bed71e7b3acdd283661ed1408abc5ddb7d8b1 Mon Sep 17 00:00:00 2001 From: Gabriel Massadas Date: Mon, 2 Oct 2023 09:20:38 +0100 Subject: [PATCH] Fix Cloudflare Access re-authorization on pwa --- packages/dashboard/src/store/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packages/dashboard/src/store/index.js b/packages/dashboard/src/store/index.js index d849c1a..5a96120 100644 --- a/packages/dashboard/src/store/index.js +++ b/packages/dashboard/src/store/index.js @@ -184,11 +184,21 @@ export default createStore({ } }, loadServerConfigs ({ commit }) { - axios.get('/api/server/config').then((response) => { + axios.get('/api/server/config', { + validateStatus: function (status) { + return status >= 200 && status < 300 + } + }).then((response) => { commit('loadServerConfigs', response.data) }).catch(function (error) { + console.log(error) if (error.response?.status === 401) { router.push({ name: 'login' }) + } else if (error.response.status === 302) { + const nextUrl = error.response.headers.Location + if (nextUrl) { + window.location.replace(nextUrl) + } } }) },