diff --git a/src/router/index.ts b/src/router/index.ts index 32f58ba..ab42861 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -59,19 +59,27 @@ router.beforeEach(async (to, from, next) => { to.name === 'my-settings' || to.name === 'my-sequences' || to.name === 'sequence' + const url = `${location.protocol}//${location.host}` + const nextRoute = `${url}${to.path}` + console.log(url) + console.log(nextRoute) if (loggedRoutes) { try { const loginUrl = `/api/users/me` const isKeycloakLogout = await axios.get(loginUrl) const isSiteLogin = !!cookies.get('user_id') if (isKeycloakLogout.status >= 300 || !isSiteLogin) { - window.location.replace(getAuthRoute('/auth/login', to.path)) + window.location.replace( + `${url}auth/login?next_url=${encodeURIComponent(nextRoute)}` + ) } else { next() } } catch (e) { - window.location.replace(getAuthRoute('/auth/login', to.path)) - next() + console.log('CAAAATCH', `${url}/api/auth/login`) + window.location.replace( + `${url}/api/auth/login?next_url=${encodeURIComponent(nextRoute)}` + ) } } else next() })