From 5d01ccf3ba9300cd0e3cbb608a804bba808531d1 Mon Sep 17 00:00:00 2001 From: survellow <59056368+survellow@users.noreply.github.com> Date: Wed, 3 Jul 2024 19:28:34 +0200 Subject: [PATCH] feat:#45 fix wrong use of redirect --- frontend/src/main.ts | 12 ++++++++++-- frontend/src/router/index.ts | 10 ++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 24f7fe3..7b2a027 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -74,6 +74,16 @@ export const createApp = ViteSSG( router = ctx.router; router.beforeEach(async (to, from) => { + if (import.meta.env.SSR) { + return; + } + + // External redirect + if (to.matched.some((record) => record.meta.redirect)) { + window.location.replace(to.meta.redirect as string); + return; + } + const newLocale = to.params.locale; const prevLocale = from.params.locale; // If the locale hasn't changed, do nothing @@ -93,8 +103,6 @@ export const createApp = ViteSSG( }, }); - //app.config.globalProperties.$hostname = "https://cal.htwk-leipzig.de" - app.use(router); app.use(ToastService); app.use(DialogService); diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 2396de9..036c92c 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -112,17 +112,19 @@ const routes : RouterOptions = { { path: "/privacy-policy", name: "privacy-policy", - redirect: "https://www.htwk-leipzig.de/hochschule/kontakt/datenschutzerklaerung/", + component: {}, meta: { - label: "privacy" + label: "privacy", + redirect: "https://www.htwk-leipzig.de/hochschule/kontakt/datenschutzerklaerung/", } }, { path: "/imprint", name: "imprint", - redirect: "https://www.htwk-leipzig.de/hochschule/kontakt/impressum/", + component: {}, meta: { - label: "imprint" + label: "imprint", + redirect: "https://www.htwk-leipzig.de/hochschule/kontakt/impressum/", } }, {