diff --git a/constants/routes/webviews.ts b/constants/routes/webviews.ts index 66a0b999f..5eda7b753 100644 --- a/constants/routes/webviews.ts +++ b/constants/routes/webviews.ts @@ -1,8 +1,8 @@ const myPages = { da: "/da/webview/scandic-friends/mine-sider", - de: "/de/webview/scandic-friends/mein-profil", + de: "/de/webview/scandic-friends/mein-bereich", en: "/en/webview/scandic-friends/my-pages", - fi: "/fi/webview/scandic-friends/minun-sivujani", + fi: "/fi/webview/scandic-friends/omat-sivut", no: "/no/webview/scandic-friends/mine-sider", sv: "/sv/webview/scandic-friends/mina-sidor", } @@ -11,7 +11,7 @@ export const overview = { da: `${myPages.da}/oversigt`, de: `${myPages.de}/uberblick`, en: `${myPages.en}/overview`, - fi: `${myPages.fi}/yleiskatsaus`, + fi: `${myPages.fi}/yleista`, no: `${myPages.no}/oversikt`, sv: `${myPages.sv}/oversikt`, } @@ -20,7 +20,7 @@ export const benefits = { da: `${myPages.da}/fordele`, de: `${myPages.de}/vorteile`, en: `${myPages.en}/benefits`, - fi: `${myPages.fi}/etuja`, + fi: `${myPages.fi}/edut`, no: `${myPages.no}/fordeler`, sv: `${myPages.sv}/formaner`, } diff --git a/middlewares/myPages.ts b/middlewares/myPages.ts index 3a1af1897..bf405209c 100644 --- a/middlewares/myPages.ts +++ b/middlewares/myPages.ts @@ -1,6 +1,11 @@ import { NextResponse } from "next/server" -import { myPages, overview } from "@/constants/routes/myPages" +import { + myPages, + overview, + profile, + profileEdit, +} from "@/constants/routes/myPages" import { env } from "@/env/server" import { internalServerError, notFound } from "@/server/errors/next" @@ -43,6 +48,25 @@ export const middleware: NextMiddleware = async (request) => { const headers = getDefaultRequestHeaders(request) headers.set("x-uid", uid) headers.set("x-contenttype", contentType) + + // Handle profile and profile edit routes, which are not CMS entries + if (profile[lang].startsWith(nextUrl.pathname)) { + return NextResponse.rewrite(new URL(`/${lang}/my-pages/profile`, nextUrl), { + request: { + headers, + }, + }) + } else if (profileEdit[lang].startsWith(nextUrl.pathname)) { + return NextResponse.rewrite( + new URL(`/${lang}/my-pages/profile/edit`, nextUrl), + { + request: { + headers, + }, + } + ) + } + return NextResponse.next({ request: { headers,