Merged in fix/LOY-483-only-english (pull request #3194)

Fix/LOY-483: Fix My Pages working in all languages

* fix(LOY-483): add back specific handling of profile pages

* fix(LOY-483): remove limit of 1 profiling consent config


Approved-by: Chuma Mcphoy (We Ahead)
This commit is contained in:
Matilda Landström
2025-11-24 10:14:57 +00:00
parent f34e88db7c
commit 29e81d9995
2 changed files with 30 additions and 1 deletions

View File

@@ -3,6 +3,9 @@ import { type NextMiddleware, NextResponse } from "next/server"
import {
myPages,
overview,
profile,
profileConsent,
profileEdit,
} from "@scandic-hotels/common/constants/routes/myPages"
import { logger } from "@scandic-hotels/common/logger"
import { findLang } from "@scandic-hotels/common/utils/languages"
@@ -49,6 +52,32 @@ export const middleware: NextMiddleware = async (request) => {
headers.set("x-uid", uid)
headers.set("x-contenttype", contentType)
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,
},
}
)
} else if (profileConsent[lang].startsWith(nextUrl.pathname)) {
return NextResponse.rewrite(
new URL(`/${lang}/my-pages/profile/consent`, nextUrl),
{
request: {
headers,
},
}
)
}
return NextResponse.next({
request: {
headers,

View File

@@ -2,7 +2,7 @@ import { gql } from "graphql-tag"
export const GetProfilingConsent = gql`
query GetProfilingConsent($locale: String!) {
all_profiling_consent(limit: 1, locale: $locale) {
all_profiling_consent(locale: $locale) {
items {
main_icon
profiling_consent_banner {